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 503da646c04338769ab72ae4cfc04af1c3241d17
parent d5f86564e52e4677243178579a625a2a78901967
Author: Jaromil <jaromil@dyne.org>
Date:   Mon, 24 Aug 2015 19:13:56 +0200

improved support for automated use in scripts
now account passwords can be saved in clear inside the conf
and the compose command can easily queue mails with attachs in outbox

Diffstat:
Msrc/zlibs/accounts | 2++
Msrc/zlibs/email | 36++++++++++++++++++++++++++++--------
2 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/src/zlibs/accounts b/src/zlibs/accounts @@ -61,6 +61,7 @@ read_account() { /^smtp_port/ { printf "smtp_port=\"%s\";", $2 } /^auth/ { printf "auth=\"%s\";", $2 } /^cert/ { printf "cert=\"%s\";", $2 } + /^password/ { printf "password=\"%s\";", $2 } /^options/ { printf "accountopt=\""; for(i=2;i<=NF;i++) printf "%s ", $i; printf "\";" } /^folders/ { printf "folders=("; for(i=2;i<=NF;i++) printf "%s ", $i; printf ");" } /^exclude/ { printf "exclude=("; for(i=2;i<=NF;i++) printf "%s ", $i; printf ");" } @@ -107,6 +108,7 @@ read_account() { func "trans: $transport" func "cert: $cert" func "auth: $auth" + [[ "$password" = "" ]] || func "password: manually set" func "options: $accountopt" func "folders: $folders" func "exclude: $exclude" diff --git a/src/zlibs/email b/src/zlibs/email @@ -22,8 +22,26 @@ # extract all emails found in stdin, one per line compose() { - # no args, open in compose mode - _mutt -H <(print "To: ${PARAM[@]}") + + # among the args parse recipient emails and files to attach + _files=() + _addrs=() + for p in ${PARAM}; do + if [[ -r $p ]]; then + func "attach: $p" + _files+=(-a $p) + elif isemail $p; then + func "recipient: $p" + _addrs+=($p) + else + warning "skipping arg: $p" + fi + done + + sysread -t 0 _stdin + + print $_stdin | _mutt ${=_files} -- ${=_addrs} + # _mutt -H <(print "To: ${PARAM[@]}") return $? } @@ -340,12 +358,14 @@ smtp_send() { QUIET=$oldquiet zkv.save smtp_fingerprints $MAILDIRS/smtp_fingerprints.zkv - - ask_password - [[ $? = 0 ]] || { - error "Error retrieving password for $login on $smtp" - unset password - return 1 } + + [[ "$password" = "" ]] && { + ask_password + [[ $? = 0 ]] || { + error "Error retrieving password for $login on $smtp" + unset password + return 1 } + } ztmp msmtpcfg=$ztmpfile