jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

commit 28ab90e4ff96fc81af1ced9124813738d0172da5
parent 94f603268199b0d5f59591ccff9ed5fdd079b7f2
Author: Jaromil <jaromil@dyne.org>
Date:   Wed, 14 Jan 2015 16:07:29 +0100

fixes to anonymous mailing via mixmaster

Diffstat:
Msrc/zlibs/addressbook | 19+++++++------------
Msrc/zlibs/email | 53+++++++++++++++++++++++++++++++----------------------
Msrc/zlibs/helpers | 16+++++++++-------
3 files changed, 47 insertions(+), 41 deletions(-)

diff --git a/src/zlibs/addressbook b/src/zlibs/addressbook @@ -137,11 +137,15 @@ learn() { [[ "$1" = "" ]] || { what="$1" } func "learning from $what" - case ${what} in + # zero e_addr map before using e_parse + e_addr=() + case ${what} in + sender|from) # simple: one address only on From: - + # now e_name e_mail and e_parsed are filled in + awk '{ print $0 } /^$/ { exit }' | e_parse From # no need to cycle, From is always only one field @@ -173,16 +177,7 @@ learn() { awk '{ print $0 } /^$/ { exit }' | e_parse To - [[ $DRYRUN == 0 ]] && { - # complex: more addresses in To: and Cc: - for _e in ${(k)e_addr}; do - _n="${e_addr[$_e]}" - insert_address "$_e" "$_n" - [[ $? = 0 ]] && { act "$list <- $_n <${_e}>" } - done - } - - e_parse Cc + awk '{ print $0 } /^$/ { exit }' | e_parse Cc [[ $DRYRUN == 0 ]] && { # complex: more addresses in To: and Cc: diff --git a/src/zlibs/email b/src/zlibs/email @@ -303,7 +303,7 @@ send() { return 1 } for qbody in ${(f)queue_outbox}; do - + func "processing outbox queue: $qbody" # clean interrupt [[ $global_quit = 1 ]] && { error "User break requested, interrupting operation" @@ -317,6 +317,22 @@ send() { _tmp_create anoncfg="$JAROTMP" + _tmp_create + msmtpcfg="$JAROTMP" + cat <<EOF > $msmtpcfg +account default +from ${email} +user ${login} +host ${smtp} +port ${smtp_port} +tls on +tls_starttls on +tls_certcheck off +logfile "${MAILDIRS}/logs/msmtp.log" +auth ${auth} +password ${password} +EOF + cat <<EOF > "$anoncfg" REMAIL n POOLSIZE 0 @@ -329,17 +345,20 @@ TYPE1LIST /var/lib/mixmaster/used-stats/rlist.txt TYPE2REL /var/lib/mixmaster/used-stats/mlist.txt TYPE2LIST /var/lib/mixmaster/used-stats/type2.list -SENDMAIL=msmtp -C $tmp -t +SENDMAIL=msmtp -C $msmtpcfg -t ERRLOG=${MAILDIRS}/logs/mixmaster.log VERBOSE=2 EOF act "Sending out anonymous email via mixmaster" - recipients=(`hdr $qbody | ${WORKDIR}/bin/fetchaddr -a -x to | cut -d, -f1`) - recipients+=(`hdr $qbody | ${WORKDIR}/bin/fetchaddr -a -x cc | cut -d, -f1`) - for r in ${recipients}; do - act "Sending to: ${r}" + e_addr=() + hdr $qbody | e_parse To + hdr $qbody | e_parse Cc + # cycle through recipients + for _e in ${(k)e_addr}; do + _n="${(v)e_addr[$_e]}" + act "Sending to: $_n <$_e>" # parse subject line anonsubj=`hdr "$qbody" | awk ' @@ -347,23 +366,13 @@ EOF 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 } -/^Mime-Version: / { print $0; next } -/^Content-Type: / { print $0; next } -/^Content-Disposition: / { print $0; next } -/^$/ { head=0 } -{ if(head==0) print $0 } -' | tee -a "$qbody.anon" | mixmaster --config=$anoncfg -m --to="$r" --subject="$anonsubj" + awk ' +BEGIN { body=0 } +/^$/ { body=1 } +{ if(body==1) print $0 } +' "$qbody" \ + | mixmaster --config="$anoncfg" -m --to="$_e" --subject="$anonsubj" res=$? - mv "$qbody.anon" "$qbody" func "mixmaster returns $res" done diff --git a/src/zlibs/helpers b/src/zlibs/helpers @@ -155,16 +155,18 @@ e_parse() { # use RFC822 parser in fetchaddr e_parsed=`${WORKDIR}/bin/fetchaddr ${=_arg} -a` - e_addr=() for _p in ${(f)e_parsed}; do _e="${(Q)_p[(ws:,:)1]:l}" # check if an email address was found - isemail "$_e" && { - _n="${(Q)_p[(ws:,:)2]}" - # reformat output using comma as separator - e_addr+=("$_e" "$_n") - func "parsed: $_n <$_e>" - } + isemail "$_e" || continue + # avoid duplicates + [[ "${(v)e_addr[$_e]}" = "" ]] || continue + + # extract also the name using comma separator + _n="${(Q)_p[(ws:,:)2]}" + + e_addr+=("$_e" "$_n") + func "parsed: $_n <$_e>" done # no emails found