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 e3c34f9020ba5ba2da783ce56849a1ccd0a11e8d
parent 33be6051eae0bb938e8c897489a8fe2376f87b59
Author: Jaromil <jaromil@dyne.org>
Date:   Fri, 18 Sep 2015 14:48:39 +0200

when fetching an explicit folder as argument, avoid applying excludes

Diffstat:
Msrc/jaro | 6+++---
Msrc/zlibs/email | 77++++++++++++++++++++++++++++++++++++++++-------------------------------------
2 files changed, 43 insertions(+), 40 deletions(-)

diff --git a/src/jaro b/src/jaro @@ -133,7 +133,7 @@ list=whitelist # global variables for accounts vars+=(name login imap imap_port smtp smtp_port protocol password auth accountopt) -typeset -ah folders exclude +arrs+=(folders exclude) vars+=(host port type) # global for server fingerprints @@ -147,7 +147,7 @@ typeset -A e_addr vars+=(e_parsed) # global array for maildirs (filled by list_maildirs) -typeset -al maildirs +arrs+=(maildirs) vars+=(last_deliver) # global variable for mutt binary @@ -632,7 +632,7 @@ main() { fetch) account=${account:-default} - fetch + fetch ${PARAM} filter_maildir incoming ;; diff --git a/src/zlibs/email b/src/zlibs/email @@ -77,25 +77,25 @@ queue() { # check if recipients are a Group if [[ "${=queue_to}" =~ '@jaromail.group' ]]; then - + groupfile="`print ${=queue_to}|cut -d@ -f1`" act "email recipients are in group ${groupfile}" - + [[ -r "$MAILDIRS/Groups/$groupfile" ]] || { maildirmake "$MAILDIRS/postponed" mv "$tmpqueue" "$MAILDIRS/postponed/new" unlock "$MAILDIRS/outbox" error "Group not found: $groupfile" return 1 } - + recipients=`grep -v '^#' $MAILDIRS/Groups/$groupfile` groupnum=`grep -v '^#' $MAILDIRS/Groups/$groupfile | wc -l` groupmode=`head -n1 "$MAILDIRS/Groups/$groupfile" | awk '/^#mode/ { print $2 } { next }'` [[ "$groupmode" = "" ]] && { groupmode="individual" } act "$groupnum recipients in total, sending mode $groupmode" - + case $groupmode in - + # individual group mode hides other recipients and send # multiple mail envelopes with each single recipient in To: individual) @@ -106,7 +106,7 @@ queue() { | deliver outbox # > "${MAILDIRS}/outbox/new/${ig}.mail" done ;; - + # carboncopy group mode sends a single envelope where all # recipients can see and reply to each other carboncopy|cc) @@ -122,7 +122,7 @@ queue() { | deliver outbox # "${MAILDIRS}/outbox/new/${ig}.mail" ;; esac - + else # recipients are set in the email envelope cat "$tmpqueue" | deliver outbox @@ -213,38 +213,42 @@ fetch() { fmconf+=(" ${accountopt} ") } # check if folders on commandline - if [[ "$PARAM[@]" = "" ]]; then + if [[ "$1" != "" ]]; then + + unset password + + act "commanded to fetch folders: $1" + folders=($1) + + + else # if no folders specified, use all [[ "$folders" == "" ]] && { folders=(`imap_list_folders`) } act "${#folders} folders found" - else - - act "commanded to fetch folders: ${PARAM[@]}" - folders=(${PARAM[@]}) + # unset here because listing folders still needed a pass + unset password + + # nothing to download, bail out with error + [[ ${#folders} == "0" ]] && return 1 + + # remove excludes + [[ ${#exclude} == "0" ]] || { + func "exclude folders: $exclude" + for e in ${exclude}; do + # fuzzy match + for f in ${folders}; do + [[ "$f" =~ "$e" ]] && { + folders=(${folders:#$f}) + } + done + done + } fi - # unset here because listing folders still needed a pass - unset password - - # nothing to download, bail out with error - [[ ${#folders} == "0" ]] && return 1 - - # remove excludes - [[ ${#exclude} == "0" ]] || { - func "exclude folders: $exclude" - for e in ${exclude}; do - # fuzzy match - for f in ${folders}; do - [[ "$f" =~ "$e" ]] && { - folders=(${folders:#$f}) - } - done - done - } func "fetch folders: $folders" # add folder configuration @@ -303,7 +307,7 @@ fetch() { } ################################################ -# read an email from stdin and send it via msmtp +# read an email from stdin and send it via msmtp smtp_send() { fn smtp-send req=(account) @@ -540,11 +544,11 @@ peek() { host=$imap port=$imap_port [[ "$password" = "" ]] && { - ask_password - [[ $? = 0 ]] || { - error "Error retrieving imap password for $login on $imap" - unset password all; return 1 - } + ask_password + [[ $? = 0 ]] || { + error "Error retrieving imap password for $login on $imap" + unset password all; return 1 + } } ztmp @@ -574,4 +578,3 @@ ${=rm} -f $tmp" # zero the tmp passfile after a second } # DRYRUN return $? } -