|
|
@@ -127,7 +127,7 @@ defaults |
|
|
|
auth on |
|
|
|
tls on |
|
|
|
tls_trust_file $mwsslcert |
|
|
|
logfile ${XDG_LOG_HOME:-$HOME}/msmtp.log |
|
|
|
#logfile ${XDG_LOG_HOME:-$HOME}/msmtp.log |
|
|
|
EOF |
|
|
|
else |
|
|
|
sed -i "/account $mwaddr/,/^\(\s*$\|account\)/d" "$mwmsmtprc" &>/dev/null |
|
|
@@ -198,7 +198,7 @@ path = $mwaccmaildir/INBOX/ |
|
|
|
[options] |
|
|
|
read_all = true |
|
|
|
delete = true |
|
|
|
message_log = ${XDG_LOG_HOME:-$HOME}/getmail.log |
|
|
|
#message_log = ${XDG_LOG_HOME:-$HOME}/getmail.log |
|
|
|
|
|
|
|
# vim: ft=conf |
|
|
|
EOF |
|
|
@@ -209,7 +209,7 @@ _mwprofiles() { |
|
|
|
# mutt |
|
|
|
[ ! -f "$mwgenmuttaccs" ] && _mwgenmuttaccs |
|
|
|
|
|
|
|
if [ "$mwtype" = "offline" ]; then |
|
|
|
if [ "$mwtype" = "offline" ]; then # not online, actually outside mutt |
|
|
|
if [ "${mwkind::3}" = "pop" ]; then |
|
|
|
_mwpop |
|
|
|
else |
|
|
@@ -222,7 +222,7 @@ _mwprofiles() { |
|
|
|
|
|
|
|
_mwtryconnect() { |
|
|
|
if [ ! -d "$mwaccmaildir" ]; then |
|
|
|
mwaccmaildirWasThere="NO" # need to remove again for "online" |
|
|
|
[ ! "${mwkind::3}" = "pop" ] && mwaccmaildirWasThere="NO" # mutt uses $mwacccachedir for "online" IMAP, so clean up later |
|
|
|
mkdir -p "$mwaccmaildir" |
|
|
|
fi |
|
|
|
if [ -z "$mwmailboxes" ]; then |
|
|
@@ -232,7 +232,7 @@ _mwtryconnect() { |
|
|
|
python -c "from poplib import $mwp;p=$mwp('$mwurl');print(p.getwelcome());p.quit()" | \ |
|
|
|
grep "+OK" && mwmailboxes="INBOX" |
|
|
|
else |
|
|
|
# for online do without mbsync, as it might not be installed |
|
|
|
# for online do without mbsync, i.e. don't require it for mail setup, either |
|
|
|
# mwmailboxes="$($mwmbsyncbin -l $mwaddr | sed 's/\//./')" >/dev/null 2>&1 |
|
|
|
[ "$mwport" = "143" ] && mwi="IMAP4" || mwi="IMAP4_SSL" |
|
|
|
mwpw="$(pass $mwpass)" |
|
|
@@ -255,17 +255,21 @@ _mwtryconnect() { |
|
|
|
|
|
|
|
_mwfinalize() { # new mwaccmuttrc |
|
|
|
if [ "$mwtype" = "online" ]; then |
|
|
|
mkdir -p "$mwacccachedir" |
|
|
|
sed -i "/IMAPStore $mwaddr-remote$/,/# End mw profile/d" "$mwmbsyncrc" &>/dev/null |
|
|
|
if [ ! "${mwkind::3}" = "pop" ]; then |
|
|
|
mkdir -p "$mwacccachedir" |
|
|
|
fi |
|
|
|
fi |
|
|
|
_mwgenmwaccmuttrc || return 1 |
|
|
|
if [ "$mwtype" = "offline" ]; then |
|
|
|
if [ "$mwtype" = "offline" ]; then # not online |
|
|
|
_mwnotmuchauto |
|
|
|
printf "All done.\\n\033[33mYou can now run \`\033[32mmw [%s]\033[33m\` to sync your mail.\033[0m\\n" "$mwaddr" |
|
|
|
elif [ "${mwkind::3}" = "pop" ]; then # and online |
|
|
|
_mwnotmuchauto #still usable for online (in mutt) pop |
|
|
|
fi |
|
|
|
if [ "$mwtype" = "online" ]; then |
|
|
|
[ "$mwaccmaildirWasThere" = "NO" ] && rm -rf "$mwaccmaildir" &>/dev/null |
|
|
|
fi |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
_mwconfirm() { |
|
|
@@ -290,7 +294,7 @@ _mwpick() { |
|
|
|
_mwdelete() { |
|
|
|
[ "$mwaccmaildirWasThere" = "NO" ] && rm -rf "$mwaccmaildir" &>/dev/null |
|
|
|
rm -f "$mwaccmuttrc" &>/dev/null |
|
|
|
if [ "$mwtype" = "offline" ]; then |
|
|
|
if [ "$mwtype" = "offline" ]; then # not online |
|
|
|
sed -i "/${mwaccmuttrc//\//\\\/}/d" "$mwgenmuttaccs" &>/dev/null |
|
|
|
sed -i "/account $mwaddr/,/^\(\s*$\|account\)/d" "$mwmsmtprc" &>/dev/null |
|
|
|
if [ -f "$mwgetmaildir/$mwaddr" ]; then |
|
|
@@ -332,7 +336,8 @@ _mwcron() { |
|
|
|
_mwasktype() { |
|
|
|
if [ -z "$mwtype" ]; then |
|
|
|
while : ; do |
|
|
|
printf "[yes/no]: Local mail via mbsync? 'no' means, that Mutt remotes, which is slower.\\n" |
|
|
|
printf "Do you want to sync your mails using the command 'mw' outside mutt? [yes/no]\\n" |
|
|
|
printf "'no' makes Neomutt slow for IMAP accounts, so probably you want 'yes'.\\n\t" |
|
|
|
read -r mwoffline |
|
|
|
case "$mwoffline" in |
|
|
|
[Yy][Ee][Ss]) mwtype="offline" && break ;; |
|
|
@@ -356,7 +361,7 @@ _mwpurge() { |
|
|
|
done |
|
|
|
rm -rf "$mwaccmuttdir"/[1-9]-*.muttrc "$mwcachedir" "$mwgenmuttaccs" |
|
|
|
sed -i "/\# mw-autogenerated/d" "$mwmuttrc" |
|
|
|
pgrep cron >/dev/null && crontab -l | sed '/mw sync/d' | crontab - >/dev/null |
|
|
|
crontab -l | sed '/mw sync/d' | crontab - >/dev/null |
|
|
|
echo "All configs and account settings have been purged." |
|
|
|
} |
|
|
|
|
|
|
@@ -390,11 +395,11 @@ _mwgenmwaccmuttrc() { |
|
|
|
mwspoolfile=$(echo "$mwmailboxes" | grep -i -m 1 inbox | sed -ne 's/.*/+\0/p') |
|
|
|
[ "${mwspoolfile/ /}" = "" ] && return 1 |
|
|
|
mwrecord=$(echo "$mwmailboxes" | grep -i -m 1 sent | sed -ne 's/.*/+\0/p') |
|
|
|
[ -z "$mwrecord" ] && mkdir -p "$mwaccmaildir/Sent/"{cur,new,tmp} && mwrecord="Sent" |
|
|
|
[ -z "$mwrecord" ] && mkdir -p "$mwaccmaildir/Sent/"{cur,new,tmp} && mwrecord="+Sent" |
|
|
|
mwpostponed=$(echo "$mwmailboxes" | grep -i -m 1 draft | sed -ne 's/.*/+\0/p') |
|
|
|
[ -z "$mwpostponed" ] && mkdir -p "$mwaccmaildir/Drafts/"{cur,new,tmp} && mwpostponed="Drafts" |
|
|
|
[ -z "$mwpostponed" ] && mkdir -p "$mwaccmaildir/Drafts/"{cur,new,tmp} && mwpostponed="+Drafts" |
|
|
|
mwtrash=$(echo "$mwmailboxes" | grep -i -m 1 trash | sed -ne 's/.*/+\0/p') |
|
|
|
[ -z "$mwtrash" ] && mkdir -p "$mwaccmaildir/Trash/"{cur,new,tmp} && mwtrash="Trash" |
|
|
|
[ -z "$mwtrash" ] && mkdir -p "$mwaccmaildir/Trash/"{cur,new,tmp} && mwtrash="+Trash" |
|
|
|
# again to reflect the change |
|
|
|
mwmailboxes="$(find "$mwaccmaildir/" -name cur | sed "s,$mwaccmaildir/,,g;s,/cur,,")" |
|
|
|
# find mwaccmuttrc ... |
|
|
@@ -411,7 +416,7 @@ _mwgenmwaccmuttrc() { |
|
|
|
# link mwaccmuttrc ... |
|
|
|
if [ "$mwtype" = "offline" ]; then |
|
|
|
! grep "source $mwaccmuttrc" "$mwgenmuttaccs" &>/dev/null && echo "source $mwaccmuttrc" >> $mwgenmuttaccs |
|
|
|
else |
|
|
|
else #online |
|
|
|
! grep "source $mwaccmuttrc" "$mwmuttrc" &>/dev/null && echo "source $mwaccmuttrc # mw-autogenerated" >> $mwmuttrc |
|
|
|
fi |
|
|
|
# (re-)generate mwaccmuttrc ... |
|
|
@@ -438,13 +443,18 @@ EOF |
|
|
|
if [ "${mwkind::3}" = "pop" ]; then |
|
|
|
cat >> "$mwaccmuttrc" <<EOF |
|
|
|
|
|
|
|
bind index gc fetch-mail |
|
|
|
bind index gm fetch-mail |
|
|
|
|
|
|
|
# pop |
|
|
|
set pop_user = "$mwkind://$mwlogin@$mwurl:$mwport" |
|
|
|
set pop_pass = `pass magenta.at/roland.puntaier@chello.at` |
|
|
|
set pop_host = "\`pass $mwpass\`" |
|
|
|
set pop_user = "$mwlogin" |
|
|
|
set pop_pass = "\`pass $mwpass\`" |
|
|
|
set pop_host = "$mwkind://$mwlogin@$mwurl:$mwport" |
|
|
|
|
|
|
|
set pop_delete = yes |
|
|
|
|
|
|
|
set folder = "$mwaccmaildir" |
|
|
|
folder-hook \$folder '$mwmuttsync' |
|
|
|
|
|
|
|
EOF |
|
|
|
else # imap |
|
|
|
mwssl=${mwkind/imap/no} |
|
|
@@ -468,7 +478,7 @@ EOF |
|
|
|
#smtp |
|
|
|
[ "$mwsport" = "25" ] && mwsmtp="smtp" || mwsmtp="smtps" |
|
|
|
cat >> "$mwaccmuttrc" <<EOF |
|
|
|
set smtp_url = "$mwsmtp://$mwlogin@$mwsmtp:$mwsport" |
|
|
|
set smtp_url = "$mwsmtp://$mwlogin@$mwsurl:$mwsport" |
|
|
|
EOF |
|
|
|
fi #online |
|
|
|
mwboxes="$(echo "$mwmailboxes" | sed -e "s/^ //g;s/.*/\"=\0\"/g" | tr "\n" " ")" |
|
|
@@ -491,12 +501,12 @@ alias me $mwname <$mwaddr> |
|
|
|
EOF |
|
|
|
IFS=$'\n' |
|
|
|
for eqbox in $mwmailboxes; do |
|
|
|
qbox=${eqbox/[/} |
|
|
|
b1=${qbox::1} |
|
|
|
box=${qbox##*/} |
|
|
|
[ "$box" = "$qbox" ] && b2=${qbox:1:1} || b2=${box:1:1} |
|
|
|
qbox="${eqbox/\[/}" |
|
|
|
b1="${qbox::1}" |
|
|
|
box="${qbox##*/}" |
|
|
|
[ "$box" = "$qbox" ] && b2="${qbox:1:1}" || b2="${box:1:1}" |
|
|
|
boxi="$b1$b2" |
|
|
|
boxi=${boxi,,} |
|
|
|
boxi="${boxi,,}" |
|
|
|
cat >> $mwaccmuttrc <<EOF |
|
|
|
macro index,pager i$boxi "<change-folder>=$eqbox<enter>" "go to $eqbox" |
|
|
|
macro index,pager M$boxi "<save-message>=$eqbox<enter>" "move mail to $eqbox" |
|
|
@@ -505,6 +515,7 @@ macro index,pager C$boxi "<copy-message>=$eqbox<enter>" "copy mail to $eqbox" |
|
|
|
EOF |
|
|
|
done |
|
|
|
unset IFS |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
if [ "$(uname)" = "Darwin" ]; then |
|
|
@@ -566,9 +577,7 @@ _mwsyncandnotify() { |
|
|
|
if [ -f "$mwgetmaildir/$mwaddr" ]; then |
|
|
|
$mwgetmailbin --rcfile=$mwaddr --getmaildir=$mwgetmaildir |
|
|
|
else |
|
|
|
tree $mwaccmaildir |
|
|
|
$mwmbsyncbin $mwaddr |
|
|
|
tree $mwaccmaildir |
|
|
|
fi |
|
|
|
mwlastrun="$mwaccmaildir/.mw.lastrun" |
|
|
|
mwnew=$(find "$mwaccmaildir/INBOX/new/" "$mwaccmaildir/Inbox/new/" "$mwaccmaildir/inbox/new/" -type f -newer "$mwlastrun" 2> /dev/null) |
|
|
@@ -592,9 +601,8 @@ _mwsyncemails() { |
|
|
|
_mwsyncandnotify |
|
|
|
done |
|
|
|
rm $XDG_CONFIG_HOME/getmail/oldmail-* &>/dev/null |
|
|
|
echo notmuch+afew ... |
|
|
|
echo notmuch new ... |
|
|
|
notmuch new &>/dev/null |
|
|
|
# notmuch also created afew MailMover target mailboxes |
|
|
|
} |
|
|
|
|
|
|
|
_mwmuttemails() { |
|
|
@@ -688,10 +696,11 @@ else |
|
|
|
cron) _mwcron ;; |
|
|
|
sync) _mwsync ;; |
|
|
|
*@*) _mwsync $1 ;; |
|
|
|
--version|-v) echo "mutt-wizard version 0.9" ;; |
|
|
|
--help|-h) cat <<EOF |
|
|
|
mw: mutt-wizard, auto-configure and sync email accounts for mutt, |
|
|
|
including mutt-independent sync of mail with \`isync\` or download of POP3 mail with \`getmail\`. |
|
|
|
|
|
|
|
|
|
|
|
Commands: |
|
|
|
add Add and autoconfigure an email address (9 max.) |
|
|
|
ls List configured accounts |
|
|
@@ -700,15 +709,15 @@ else |
|
|
|
cron Enable or disable an autosync via cronjob |
|
|
|
sync sync/download mail based on config in $mwmbsyncrc and $mwgetmaildir |
|
|
|
--help|-h Print this message |
|
|
|
|
|
|
|
|
|
|
|
With no parameter all configured emails are synced and all account muttrc's are created. |
|
|
|
With a parameter containing a @, an mail is assumed and that account is synced. |
|
|
|
|
|
|
|
|
|
|
|
Config requirements: |
|
|
|
|
|
|
|
|
|
|
|
- mbsyncrc: "Path" ends in email |
|
|
|
- getmail: config file name = email, "path" ends in email |
|
|
|
|
|
|
|
|
|
|
|
EOF |
|
|
|
esac |
|
|
|
|
|
|
|