commit cc958892a5af48c04733acb72745a986402613a2
parent c486b45ac27817fa67714d062cdbd2c976fa453a
Author: Jaromil <jaromil@dyne.org>
Date:   Mon,  5 May 2014 09:47:21 +0200
better header parsis for anonymous emails
Diffstat:
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/zlibs/email b/src/zlibs/email
@@ -365,17 +365,23 @@ VERBOSE=2
 EOF
 
 	    act "Sending out anonymous email via mixmaster"
-	    act "`head -n 20 $qbody | grep '^Subject:'`"
 	    recipients=(`cat $qbody | fetchaddr -a -x to | cut -d, -f1`)
 	    recipients+=(`cat $qbody | fetchaddr -a -x cc | cut -d, -f1`)
 	    for r in ${recipients}; do
 		act "Sending to: ${r}"
+
+		# parse subject line
+		anonsubj=`head -n 20 "$qbody" | awk '
+/^Subject: / { for(i=2;i<=NF;i++) printf "%s ", $i }'`
+		act "Subject: $anonsubj"
+
 		# strip headers and send via mixmaster
 		cat  "$qbody" | awk '
 BEGIN { head=1 }
 /^To: /           { print $0; next }
 /^Cc: /           { print $0; next }
 /^Bcc: /          { print $0; next }
+/^Date: /         { print $0; next }
 /^Subject: /      { print $0; next }
 /^In-Reply-To: /  { print $0; next }
 /^References: /   { print $0; next }
@@ -384,8 +390,9 @@ BEGIN { head=1 }
 /^Content-Disposition: / { print $0; next }
 /^$/ { head=0 }
 { if(head==0) print $0 }
-' | mixmaster --config=$anoncfg -m --to="$r"
+' | tee -a "$qbody.anon" | mixmaster --config=$anoncfg -m --to="$r" --subject="$anonsubj"
 		res=$?
+		mv "$qbody.anon" "$qbody"
 		func "mixmaster returns $res"
 	    done