Browse Source

all debug mail goes to cropswap-debug@shandan.one

Pi 1 year ago
parent
commit
1666463463
3 changed files with 15 additions and 13 deletions
  1. 12 9
      cropswap-debug.sh
  2. 1 4
      cropswap-sendmail.sh
  3. 2 0
      maildroprc

+ 12 - 9
cropswap-debug.sh

@@ -1,17 +1,20 @@
 #!/bin/bash
 set -euo pipefail
+
+CROPSWAPDEBUG=cropswap-debug@shandan.one
+SENDMAIL=/usr/sbin/sendmail
+
 if (( TEST != 0)); then
 	cat -
-	cat <<EOF >&2
-ERROR ${1:-unknown}
-$(env)
-EOF
-
+	cat <<-EOF >&2
+	ERROR ${1:-unknown}
+	$(env)
+	EOF
 else
-	cat - <<EOF | /usr/sbin/sendmail -f maildrop pi
+	cat /proc/self/fd/5 - 5< <(cat -) <<-EOF | "$SENDMAIL" -F "${FROM:-}" -f "${MAILGROUP:-}" "${CROPSWAPDEBUG}"
 
-ERROR ${1:-unknown}
-$(env)
-EOF
+	ERROR ${1:-unknown}
+	$(env)
+	EOF
 fi
 exit ${EXITCODE:-0}

+ 1 - 4
cropswap-sendmail.sh

@@ -19,7 +19,6 @@ in_group_aliases(){
 	return 1
 }
 CROPSWAPARCHIVE=cropswap-archive@shandan.one
-CROPSWAPDEBUG=cropswap-debug@shandan.one
 ITER_SUBS=/opt/cropswap/gdbm-iter-subscriptions.py
 MIME_INJECT=/opt/cropswap/mime-inject.py
 DELIVERED=false
@@ -89,10 +88,8 @@ then
 	< mail | "$SENDMAIL" -F "${FROM}" -f "${MAILGROUP}" "${CROPSWAPARCHIVE}"
 fi
 
-"$SENDMAIL" -F "${FROM}" -f "${MAILGROUP}" "${CROPSWAPDEBUG}" < mail || true
-
+"$DEBUGMAIL" "delivered:$DELIVERED" < mail || true
 if ! $DELIVERED; then
-	"$DEBUGMAIL" undelivered
 	exit "$UNHANDLED"
 else
 	exit 0

+ 2 - 0
maildroprc

@@ -36,6 +36,8 @@ ORGANIZERGROUP="cropswap@shandan.one"
 # From subscribed member -> other subscribed members
 MEMBERGROUP="cropswap-members@shandan.one"
 
+cc "|$DEBUGMAIL processing"
+
 if ($FROM eq "")
 {
    EXITCODE=$UNHANDLED