From 96c0073ecfa9d8063404c23b48570287adf1544d Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 9 Jul 2020 17:50:01 -0400 Subject: mailsync and cron removed, mw sync added --- bin/mw | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index c7a5c62..d04204b 100755 --- a/bin/mw +++ b/bin/mw @@ -97,7 +97,7 @@ bind index,pager g noop bind index,pager M noop bind index,pager C noop bind index gg first-entry -macro index o \"mailsync -V $title\" \"run mbsync to sync $title\" +macro index o \"mbsync -V $title\" \"run mbsync to sync $title\" unmailboxes * " else @@ -286,27 +286,6 @@ delete() { sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; sed -ibu "/account $title/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu } -choosecron() { ! pgrep cron >/dev/null && echo "No cron manager running. Install/enable one and then select this option again." && return 1 - if crontab -l | grep mailsync >/dev/null; then - echo "Active mail sync cronjob detected. Do you want to remove it?" - printf "\033[36m\t" - read -r rmyn - printf "\033[0m" - echo "$rmyn" | grep -i "^y\(es\)*$" >/dev/null && crontab -l | sed '/mailsync/d' | crontab - >/dev/null && echo "Mail sync turned off." - else - echo "How many minutes between each mail sync?" - printf "\033[36m\t" - read -r minnum - printf "\033[0m" - while ! echo "$minnum" | grep "^[0-9]\+$" >/dev/null; do - printf "That doesn't look like a number. How many minutes between each mail sync?\\n\033[36m\t" - read -r minnum - printf "\033[0m" - done - (crontab -l; echo "*/$minnum * * * * $(type mailsync | cut -d' ' -f3) >/dev/null 2>&1") | crontab - >/dev/null && - echo "Cronjob added. Mail will sync every $minnum minutes. Be sure you have your cron manager running." - fi ;} - asktype() { while : ; do printf "Do you want to keep your mail for this account offline with mbsync? [yes/no]\\n\t" read -r offnot @@ -318,11 +297,17 @@ asktype() { while : ; do purge() { confirm "delete all account data" || exit rm -rf "$mbsyncrc" "$accdir" "$HOME/.config/msmtp" "$cachedir" - crontab -l | sed '/mailsync/d' | crontab - >/dev/null echo "All configs and account settings have been purged." sed -ibu "/\# mw-autogenerated/d" "$muttrc" ; rm -f "$muttrc"bu } +syncwrapper() { mbsync -a & + ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null + wait + ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null + notmuch new +} + notmuchauto() { \ [ -z "$NOTMUCH_CONFIG" ] && NOTMUCH_CONFIG="$HOME/.notmuch-config" [ -f "$NOTMUCH_CONFIG" ] && return 0 @@ -349,8 +334,8 @@ case "$1" in add) asktype && askinfo && tryconnect && finalize || delete ;; pass) pick "change the password of" && getpass ;; delete) pick delete && confirm "delete the \`$title\` profile" && delete ;; + sync) syncwrapper ;; purge) purge ;; - cron) choosecron ;; *) cat << EOF mw: mutt-wizard, auto-configure email accounts for mutt including downloadable mail with \`isync\`. @@ -360,7 +345,7 @@ Allowed options: ls List configured accounts delete Pick an account to delete purge Delete all accounts and settings - cron Enable or disable an autosync via cronjob + sync Syncs mail and updates notmuch database all else Print this message NOTE: Once at least one account is added, you can run -- cgit v1.2.3 From aece24c7ddb058589273e5e0b7cc89b70d6a54e1 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 27 Aug 2020 16:38:14 -0400 Subject: revert auto gpg to fix #491 #484 #493 etc --- bin/mw | 12 ------------ share/mutt-wizard.muttrc | 5 +++++ 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 41e07e7..c0528de 100755 --- a/bin/mw +++ b/bin/mw @@ -87,11 +87,6 @@ set header_cache = $cachedir/$title/headers set message_cachedir = $cachedir/$title/bodies set mbox_type = Maildir -set crypt_autosign = yes -set crypt_opportunistic_encrypt = yes -set pgp_self_encrypt = yes -set pgp_default_key = $keyid - bind index,pager gg noop bind index,pager g noop bind index,pager M noop @@ -113,12 +108,6 @@ set header_cache = $cachedir/$title/headers set message_cachedir = $cachedir/$title/bodies set imap_pass = \"\`pass mutt-wizard-$title\`\" -set crypt_autosign = yes -set crypt_opportunistic_encrypt = yes -set pgp_self_encrypt = yes -set pgp_default_key = $keyid - - set mbox_type = Maildir set ssl_starttls = yes set ssl_force_tls = yes @@ -137,7 +126,6 @@ fi askinfo() { \ printf "Insert the \033[31memail address\033[0m that you want to autoconfigure for mutt/mbsync\\n\tEmail: \033[36m" read -r fulladdr - keyid=$("$GPG" --list-keys --with-colons "$fulladdr" | awk -F: '/^pub:/ { print $5 }') printf "\033[0m" while ! echo "$fulladdr" | grep "$emailre" >/dev/null; do printf "That is not a valid \033[31memail address\033[0m, please retype the desired email.\\n\\nEmail: \033[36m\t" diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc index aafb3d5..e7fa8c8 100644 --- a/share/mutt-wizard.muttrc +++ b/share/mutt-wizard.muttrc @@ -63,6 +63,11 @@ bind pager \031 previous-line # Mouse wheel bind pager \005 next-line # Mouse wheel bind editor complete-query +#set crypt_autosign = yes +#set crypt_opportunistic_encrypt = yes +#set pgp_self_encrypt = yes +#set pgp_default_key = 'your@gpgemailaddre.ss' + macro index,pager a "set my_pipe_decode=\$pipe_decode pipe_decodeabook --add-emailset pipe_decode=\$my_pipe_decode; unset my_pipe_decode" "add the sender address to abook" macro index \Cr "T~UN." "mark all messages as read" macro index O "mbsync -a" "run mbsync to sync all mail" -- cgit v1.2.3 From f87acd70421a177b4b63120e6c9c3b17ab3c369f Mon Sep 17 00:00:00 2001 From: "A. Tammy" Date: Thu, 27 Aug 2020 16:43:24 -0400 Subject: fix regex check for email address (#511) -E option is cross platform and interprets pattern as regular expression always Co-authored-by: Aisha Tammy --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index c0528de..2d32859 100755 --- a/bin/mw +++ b/bin/mw @@ -14,7 +14,7 @@ muttdir="$HOME/.config/mutt" # Main mutt config location accdir="$muttdir/accounts" # Directory for account settings maildir="$HOME/.local/share/mail" # Location of mail storage namere="^[a-z_][a-z0-9_-]*$" # Regex to ensure viable username -emailre=".\+@.\+\\..\+" # Regex to confirm valid email address +emailre=".+@.+\..+" # Regex to confirm valid email address muttshare="$prefix/share/mutt-wizard" mbsyncrc="$HOME/.mbsyncrc" mwconfig="$muttshare/mutt-wizard.muttrc" @@ -127,7 +127,7 @@ askinfo() { \ printf "Insert the \033[31memail address\033[0m that you want to autoconfigure for mutt/mbsync\\n\tEmail: \033[36m" read -r fulladdr printf "\033[0m" - while ! echo "$fulladdr" | grep "$emailre" >/dev/null; do + while ! echo "$fulladdr" | grep -E "$emailre" >/dev/null; do printf "That is not a valid \033[31memail address\033[0m, please retype the desired email.\\n\\nEmail: \033[36m\t" read -r fulladdr printf "\033[0m" -- cgit v1.2.3 From 9910b434c2a1ce21dc7f5db7336b78eb645d959b Mon Sep 17 00:00:00 2001 From: Lorenzo Leonardini Date: Thu, 27 Aug 2020 22:46:36 +0200 Subject: Top-level domain wildcard (#475) --- bin/mw | 4 +++ share/domains.csv | 77 ++++++++----------------------------------------------- 2 files changed, 14 insertions(+), 67 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 2d32859..f8d9d7b 100755 --- a/bin/mw +++ b/bin/mw @@ -149,6 +149,10 @@ askinfo() { \ esac printf "\\nSearching for \033[32m%s\033[0m in \033[34m\`domains.csv\`\033[0m..." "$domain" serverinfo="$(grep "^$search_query" "$muttshare/domains.csv" 2>/dev/null)" + if [ -z "$serverinfo" ]; then + search_query=$(echo "$search_query" | sed "s/\.[^\.]*$/\.\\\*/") + serverinfo="$(grep "^$search_query" "$muttshare/domains.csv" 2>/dev/null)" + fi if [ -z "$serverinfo" ]; then printf "Your email domain is not in mutt-wizard's database yet.\\nmutt-wizard will still autoconfigure everything, but you will have to manually type in your service's IMAP and SMTP server information.\\nYou can usually quickly find this by internet searching for it.\\n" printf "Insert the IMAP server for your email provider (excluding the port number)\\n\033[36m\t" diff --git a/share/domains.csv b/share/domains.csv index a6abfc6..9db3601 100644 --- a/share/domains.csv +++ b/share/domains.csv @@ -96,64 +96,20 @@ fsu-jena,exchange.uni-jena.de,993,smtp.uni-jena.de,587 gcc.edu,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 getbackinthe.kitchen,mail.cock.li,993,mail.cock.li,587 gmail.com,imap.gmail.com,993,smtp.gmail.com,587 -gmx.at,imap.gmx.net,993,mail.gmx.net,587 -gmx.com,imap.gmx.net,993,mail.gmx.net,587 -gmx.de,imap.gmx.net,993,mail.gmx.net,587 -gmx.eu,imap.gmx.net,993,mail.gmx.net,587 -gmx.fr,imap.gmx.com,993,mail.gmx.com,587 -gmx.info,imap.gmx.net,993,mail.gmx.net,587 -gmx.net,imap.gmx.net,993,mail.gmx.net,587 -gmx.org,imap.gmx.net,993,mail.gmx.net,587 +gmx.*,imap.gmx.net,993,mail.gmx.net,587 go2.pl,poczta.o2.pl,993,poczta.o2.pl,465 goat.si,mail.cock.li,993,mail.cock.li,587 googlemail.com,imap.googlemail.com,993,smtp.googlemail.com,587 grrlz.net,mail.autistici.org,993,smtp.autistici.org,465 -hacari.com,mail.autistici.org,993,smtp.autistici.org,465 -hacari.net,mail.autistici.org,993,smtp.autistici.org,465 -hacari.org,mail.autistici.org,993,smtp.autistici.org,465 +hacari.*,mail.autistici.org,993,smtp.autistici.org,465 helsinki.fi,outlook.office365.com,993,smtp.helsinki.fi,587 hhu.de,mail.hhu.de,993,mail.hhu.de,465 hitler.rocks,mail.cock.li,993,mail.cock.li,587 horsefucker.org,mail.cock.li,993,mail.cock.li,587 hostgator,gator4171.hostgator.com,993,gator4171.hostgator.com,587 -hotmail.be,outlook.office365.com,993,smtp.office365.com,587 -hotmail.ca,outlook.office365.com,993,smtp.office365.com,587 -hotmail.cl,outlook.office365.com,993,smtp.office365.com,587 -hotmail.co.id,outlook.office365.com,993,smtp.office365.com,587 -hotmail.co.il,outlook.office365.com,993,smtp.office365.com,587 -hotmail.co.in,outlook.office365.com,993,smtp.office365.com,587 -hotmail.co.jp,outlook.office365.com,993,smtp.office365.com,587 -hotmail.co.kr,outlook.office365.com,993,smtp.office365.com,587 -hotmail.co.th,outlook.office365.com,993,smtp.office365.com,587 -hotmail.co.uk,outlook.office365.com,993,smtp.office365.com,587 -hotmail.co.za,outlook.office365.com,993,smtp.office365.com,587 -hotmail.com,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 -hotmail.com.ar,outlook.office365.com,993,smtp.office365.com,587 -hotmail.com.au,outlook.office365.com,993,smtp.office365.com,587 -hotmail.com.br,outlook.office365.com,993,smtp.office365.com,587 -hotmail.com.hk,outlook.office365.com,993,smtp.office365.com,587 -hotmail.com.tr,outlook.office365.com,993,smtp.office365.com,587 -hotmail.com.tw,outlook.office365.com,993,smtp.office365.com,587 -hotmail.com.vn,outlook.office365.com,993,smtp.office365.com,587 -hotmail.cz,outlook.office365.com,993,smtp.office365.com,587 -hotmail.de,outlook.office365.com,993,smtp.office365.com,587 -hotmail.dk,outlook.office365.com,993,smtp.office365.com,587 -hotmail.es,outlook.office365.com,993,smtp.office365.com,587 -hotmail.fi,outlook.office365.com,993,smtp.office365.com,587 -hotmail.fr,outlook.office365.com,993,smtp.office365.com,587 -hotmail.gr,outlook.office365.com,993,smtp.office365.com,587 -hotmail.hu,outlook.office365.com,993,smtp.office365.com,587 -hotmail.it,outlook.office365.com,993,smtp.office365.com,587 -hotmail.lt,outlook.office365.com,993,smtp.office365.com,587 -hotmail.lv,outlook.office365.com,993,smtp.office365.com,587 -hotmail.my,outlook.office365.com,993,smtp.office365.com,587 -hotmail.nl,outlook.office365.com,993,smtp.office365.com,587 -hotmail.no,outlook.office365.com,993,smtp.office365.com,587 -hotmail.ph,outlook.office365.com,993,smtp.office365.com,587 -hotmail.rs,outlook.office365.com,993,smtp.office365.com,587 -hotmail.se,outlook.office365.com,993,smtp.office365.com,587 -hotmail.sg,outlook.office365.com,993,smtp.office365.com,587 -hotmail.sk,outlook.office365.com,993,smtp.office365.com,587 +hotmail.*,outlook.office365.com,993,smtp.office365.com,587 +hotmail.co.*,outlook.office365.com,993,smtp.office365.com,587 +hotmail.com.*,outlook.office365.com,993,smtp.office365.com,587 hs-mittweida.de,mail.hs-mittweida.de,993,mail.hs-mittweida.de,465 humbug.pw,imap.migadu.com,993,smtp.migadu.com,587 hushmail.com,imap.hushmail.com,993,smtp.hushmail.com,465 @@ -166,8 +122,7 @@ infomaniak.com,imap.infomaniak.com,993,imap.infomaniak.com,587 insiberia.net,mail.autistici.org,993,smtp.autistici.org,465 insicuri.net,mail.autistici.org,993,smtp.autistici.org,465 interactio.io,imap.gmail.com,993,smtp.gmail.com,587 -interia.eu,poczta.interia.pl,993,poczta.interia.pl,465 -interia.pl,poczta.interia.pl,993,poczta.interia.pl,465 +interia.*,poczta.interia.pl,993,poczta.interia.pl,465 inventati.org,mail.autistici.org,993,smtp.autistici.org,465 ionos.de,imap.ionos.de,993,smtp.ionos.de,587 itu.dk,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 @@ -220,9 +175,7 @@ online.de,imap.1und1.de,993,smtp.1und1.de,465 op.pl,imap.poczta.onet.pl,993,smtp.poczta.onet.pl,465 opoczta.pl,imap.poczta.onet.pl,993,smtp.poczta.onet.pl,465 orange.fr,imap.orange.fr,993,smtp.orange.fr,465 -outlook.at,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 -outlook.com,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 -outlook.de,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 +outlook.*,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 outlook.es,outlook.office365.com,993,smtp.office365.com,587 paranoici.org,mail.autistici.org,993,smtp.autistici.org,465 pm.me,127.0.0.1,1143,127.0.0.1,1025 @@ -230,10 +183,8 @@ poczta.fm,poczta.interia.pl,993,poczta.interia.pl,465 poczta.onet.pl,imap.poczta.onet.pl,993,smtp.poczta.onet.pl,465 polimi.it,outlook.office365.com,993,smtp.office365.com,587 polito.it,mail.polito.it,993,mail.polito.it,465 -polito.it,mail.polito.it,993,mail.polito.it,465 post.com,imap.mail.com,993,smtp.mail.com,587 -posteo.de,posteo.de,993,posteo.de,587 -posteo.net,posteo.de,993,posteo.de,587 +posteo.*,posteo.de,993,posteo.de,587 privacyrequired.com,mail.autistici.org,993,smtp.autistici.org,465 prokonto.pl,poczta.o2.pl,993,poczta.o2.pl,465 protonmail.ch,127.0.0.1,1143,127.0.0.1,1025 @@ -264,7 +215,6 @@ studenti.unipi.it,outlook.office365.com,993,smtp.office365.com,587 students.rmcacs.org,imap.gmail.com,993,smtp.gmail.com,587 students.southwales.ac.uk,imap.gmail.com,993,smtp.gmail.com,587 studio.unibo.it,outlook.office365.com,993,smtp.office365.com,587 -studio.unibo.it,outlook.office365.com,993,smtp.office365.com,587 studserv.uni-leipzig.de,studserv.uni-leipzig.de,993,studserv.uni-leipzig.de,25 subvertising.org,mail.autistici.org,993,smtp.autistici.org,465 t-online.de,secureimap.t-online.de,993,securesmtp.t-online.de,465 @@ -309,15 +259,8 @@ wit.edu,outlook.office365.com,993,smtp.office365.com,587 wp.pl,imap.wp.pl,993,smtp.wp.pl,465 writeme.com,imap.mail.com,993,smtp.mail.com,587 ya.ru,imap.yandex.com,993,smtp.yandex.com,587 -yahoo.com,imap.mail.yahoo.com,993,smtp.mail.yahoo.com,587 -yahoo.fr,imap.mail.yahoo.com,993,smtp.mail.yahoo.com,587 -yahoo.gr,imap.mail.yahoo.com,993,smtp.mail.yahoo.com,587 -yandex.by,imap.yandex.com,993,smtp.yandex.com,587 -yandex.com,imap.yandex.com,993,smtp.yandex.com,587 -yandex.kz,imap.yandex.com,993,smtp.yandex.com,587 -yandex.net,imap.yandex.com,993,smtp.yandex.com,587 -yandex.ru,imap.yandex.com,993,smtp.yandex.com,587 -yandex.ua,imap.yandex.com,993,smtp.yandex.com,587 +yahoo.*,imap.mail.yahoo.com,993,smtp.mail.yahoo.com,587 +yandex.*,imap.yandex.com,993,smtp.yandex.com,587 ymail.com,imap.mail.yahoo.com,993,smtp.mail.yahoo.com,465 zaclys.net,mail.zaclys.net,993,mail.zaclys.net,465 zoho.com,imap.zoho.com,993,smtp.zoho.com,465 -- cgit v1.2.3 From 38213235727efb7e70a67d8bf3d92a13a2c479eb Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 27 Aug 2020 16:54:06 -0400 Subject: mw sync can take arg, otherwise sync all --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index c0528de..c83274f 100755 --- a/bin/mw +++ b/bin/mw @@ -289,7 +289,7 @@ purge() { confirm "delete all account data" || exit sed -ibu "/\# mw-autogenerated/d" "$muttrc" ; rm -f "$muttrc"bu } -syncwrapper() { mbsync -a & +syncwrapper() { mbsync "${1:--a}" & ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null wait ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null @@ -322,7 +322,7 @@ case "$1" in add) asktype && askinfo && tryconnect && finalize || delete ;; pass) pick "change the password of" && getpass ;; delete) pick delete && confirm "delete the \`$title\` profile" && delete ;; - sync) syncwrapper ;; + sync) syncwrapper $2 ;; purge) purge ;; *) cat << EOF mw: mutt-wizard, auto-configure email accounts for mutt -- cgit v1.2.3 From 06f416f5eb73c4d01df25046d17a1cfdbfb116ae Mon Sep 17 00:00:00 2001 From: Jonassenher Date: Sun, 30 Aug 2020 18:28:21 +0200 Subject: Support for XDG Base Directory Today's mutt-wizard does not support the XDG Base Directory specifications (https://wiki.archlinux.org/index.php/XDG_Base_Directory) because it says the user should be able to change the config, cache, data folders etc. using the environmental variables XDG_CONFIG_HOME, XDG_CACHE_HOME, and XDG_DATA_HOME, and instead hard codes the default paths ~/.config, ~/.cache, and ~/.local/share. My commit corrects this. --- bin/mw | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 9f39cc4..fffc965 100755 --- a/bin/mw +++ b/bin/mw @@ -10,17 +10,17 @@ command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" ! command -v mbsync >/dev/null && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit prefix="/usr/local" -muttdir="$HOME/.config/mutt" # Main mutt config location +muttdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" # Main mutt config location accdir="$muttdir/accounts" # Directory for account settings -maildir="$HOME/.local/share/mail" # Location of mail storage +maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" # Location of mail storage namere="^[a-z_][a-z0-9_-]*$" # Regex to ensure viable username emailre=".+@.+\..+" # Regex to confirm valid email address muttshare="$prefix/share/mutt-wizard" -mbsyncrc="$HOME/.mbsyncrc" +mbsyncrc="${MBSYNCRC_HOME:-$HOME/.mbsyncrc}" mwconfig="$muttshare/mutt-wizard.muttrc" -cachedir="$HOME/.cache/mutt-wizard" +cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard" muttrc="$muttdir/muttrc" -msmtprc="$HOME/.config/msmtp/config" +msmtprc="${XDG_CACHE_HOME:-$HOME/.config}/msmtp/config" ssltype="IMAPS" # This is later changed to `None` later in the script if using Protonmail for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/" @@ -38,7 +38,7 @@ msmtp_header="defaults auth on tls on tls_trust_file $sslcert -logfile ~/.config/msmtp/msmtp.log +logfile $XDG_CONFIG_HOME/msmtp/msmtp.log " msmtp_profile="account $title host $smtp @@ -59,8 +59,8 @@ CertificateFile $sslcert MaildirStore $title-local Subfolders Verbatim -Path ~/.local/share/mail/$title/ -Inbox ~/.local/share/mail/$title/INBOX +Path $XDG_DATA_HOME/mail/$title/ +Inbox $XDG_DATA_HOME/mail/$title/INBOX Flatten . Channel $title -- cgit v1.2.3 From d60d2398869796ee1fd7e6c424afe11654e2e702 Mon Sep 17 00:00:00 2001 From: Jonassenher Date: Sun, 30 Aug 2020 19:02:15 +0200 Subject: Fixed the case for no environmental variables --- bin/mw | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index fffc965..5e5a610 100755 --- a/bin/mw +++ b/bin/mw @@ -38,7 +38,7 @@ msmtp_header="defaults auth on tls on tls_trust_file $sslcert -logfile $XDG_CONFIG_HOME/msmtp/msmtp.log +logfile ${XDG_CONFIG_HOME/:-$HOME/.config}/msmtp/msmtp.log " msmtp_profile="account $title host $smtp @@ -59,8 +59,8 @@ CertificateFile $sslcert MaildirStore $title-local Subfolders Verbatim -Path $XDG_DATA_HOME/mail/$title/ -Inbox $XDG_DATA_HOME/mail/$title/INBOX +Path ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$title/ +Inbox ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$title/INBOX Flatten . Channel $title -- cgit v1.2.3 From f00fa04f15c479dd32dbd9802602f6adbcefbbed Mon Sep 17 00:00:00 2001 From: Jonassenher Date: Sun, 30 Aug 2020 19:26:10 +0200 Subject: Fixed mbsync using the correct rc file --- bin/mw | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 5e5a610..c0c6f7a 100755 --- a/bin/mw +++ b/bin/mw @@ -10,11 +10,11 @@ command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" ! command -v mbsync >/dev/null && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit prefix="/usr/local" -muttdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" # Main mutt config location -accdir="$muttdir/accounts" # Directory for account settings +muttdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" # Main mutt config location +accdir="$muttdir/accounts" # Directory for account settings maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" # Location of mail storage -namere="^[a-z_][a-z0-9_-]*$" # Regex to ensure viable username -emailre=".+@.+\..+" # Regex to confirm valid email address +namere="^[a-z_][a-z0-9_-]*$" # Regex to ensure viable username +emailre=".+@.+\..+" # Regex to confirm valid email address muttshare="$prefix/share/mutt-wizard" mbsyncrc="${MBSYNCRC_HOME:-$HOME/.mbsyncrc}" mwconfig="$muttshare/mutt-wizard.muttrc" @@ -22,6 +22,7 @@ cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard" muttrc="$muttdir/muttrc" msmtprc="${XDG_CACHE_HOME:-$HOME/.config}/msmtp/config" ssltype="IMAPS" # This is later changed to `None` later in the script if using Protonmail +alias mbsync='mbsync -c "$mbsyncrc"' for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/" do -- cgit v1.2.3 From 8b1ba846d03009e4e771725727856f58be1c33cf Mon Sep 17 00:00:00 2001 From: Jonassenher Date: Sun, 30 Aug 2020 21:22:35 +0200 Subject: fix --- bin/mw | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index c0c6f7a..57fd7b5 100755 --- a/bin/mw +++ b/bin/mw @@ -20,7 +20,7 @@ mbsyncrc="${MBSYNCRC_HOME:-$HOME/.mbsyncrc}" mwconfig="$muttshare/mutt-wizard.muttrc" cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard" muttrc="$muttdir/muttrc" -msmtprc="${XDG_CACHE_HOME:-$HOME/.config}/msmtp/config" +msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" ssltype="IMAPS" # This is later changed to `None` later in the script if using Protonmail alias mbsync='mbsync -c "$mbsyncrc"' @@ -193,7 +193,7 @@ EOF echo "$maxmes" | grep "[1-9]" >/dev/null || maxmes="0" getpass getprofiles - mkdir -p "$muttdir" "$accdir" "$cachedir/$title/bodies" "$HOME/.config/msmtp" + mkdir -p "$muttdir" "$accdir" "$cachedir/$title/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" getaccounts for x in $(seq 1 9); do echo "$accounts" | grep "$x" >/dev/null 2>&1 || { export idnum="$x"; break ;}; done [ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc" @@ -203,6 +203,7 @@ EOF protonmail.ch|protonmail.com|pm.me) protonfinger || return 1 ;; esac echo "$mutt_profile" > "$accdir/$idnum-$title.muttrc" + mkdir -p "${mbsyncrc%/*}" echo "$mbsync_profile" >> "$mbsyncrc" notmuchauto [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" && echo "muttrc created." @@ -289,7 +290,7 @@ asktype() { while : ; do esac; done ;} purge() { confirm "delete all account data" || exit - rm -rf "$mbsyncrc" "$accdir" "$HOME/.config/msmtp" "$cachedir" + rm -rf "$mbsyncrc" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$cachedir" echo "All configs and account settings have been purged." sed -ibu "/\# mw-autogenerated/d" "$muttrc" ; rm -f "$muttrc"bu } -- cgit v1.2.3 From 113499cf740a7a4473ac33414ec833d4fd9c9633 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 31 Aug 2020 16:57:19 -0400 Subject: tweaks --- bin/mw | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 57fd7b5..ca090c3 100755 --- a/bin/mw +++ b/bin/mw @@ -16,11 +16,12 @@ maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" # Location of mail storage namere="^[a-z_][a-z0-9_-]*$" # Regex to ensure viable username emailre=".+@.+\..+" # Regex to confirm valid email address muttshare="$prefix/share/mutt-wizard" -mbsyncrc="${MBSYNCRC_HOME:-$HOME/.mbsyncrc}" +mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" mwconfig="$muttshare/mutt-wizard.muttrc" cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard" muttrc="$muttdir/muttrc" msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" +msmtplog="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/msmtp.log" ssltype="IMAPS" # This is later changed to `None` later in the script if using Protonmail alias mbsync='mbsync -c "$mbsyncrc"' @@ -39,7 +40,7 @@ msmtp_header="defaults auth on tls on tls_trust_file $sslcert -logfile ${XDG_CONFIG_HOME/:-$HOME/.config}/msmtp/msmtp.log +logfile $msmtplog " msmtp_profile="account $title host $smtp @@ -328,7 +329,7 @@ case "$1" in add) asktype && askinfo && tryconnect && finalize || delete ;; pass) pick "change the password of" && getpass ;; delete) pick delete && confirm "delete the \`$title\` profile" && delete ;; - sync) syncwrapper $2 ;; + sync) syncwrapper "$2" ;; purge) purge ;; *) cat << EOF mw: mutt-wizard, auto-configure email accounts for mutt -- cgit v1.2.3 From faa5f2aad9daa9fafc80df96968cff1ebbda06f8 Mon Sep 17 00:00:00 2001 From: Laura Powles Date: Sat, 26 Sep 2020 19:40:56 +1000 Subject: changed the prefix for password files into a variable so that it can be edited more easily --- bin/mw | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index ca090c3..f501638 100755 --- a/bin/mw +++ b/bin/mw @@ -10,6 +10,7 @@ command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" ! command -v mbsync >/dev/null && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit prefix="/usr/local" +pass_prefix="mutt-wizard-" muttdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" # Main mutt config location accdir="$muttdir/accounts" # Directory for account settings maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" # Location of mail storage @@ -47,14 +48,14 @@ host $smtp port $sport from $fulladdr user $login -passwordeval \"pass mutt-wizard-$title\" +passwordeval \"pass $pass_prefix$title\" $starttlsoff " mbsync_profile="IMAPStore $title-remote Host $imap Port $iport User $login -PassCmd \"pass mutt-wizard-$title\" +PassCmd \"pass $pass_prefix$title\" AuthMechs LOGIN SSLType $ssltype CertificateFile $sslcert @@ -108,7 +109,7 @@ set folder = \"imaps://$login@$imap:$iport\" set imap_user = \"$login\" set header_cache = $cachedir/$title/headers set message_cachedir = $cachedir/$title/bodies -set imap_pass = \"\`pass mutt-wizard-$title\`\" +set imap_pass = \"\`pass $pass_prefix$title\`\" set mbox_type = Maildir set ssl_starttls = yes @@ -218,8 +219,8 @@ protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" sed -ibu "s/account $title/&\ntls_trust_file\ntls_fingerprint $fingerprint/" "$msmtprc" ; rm -f "$msmtprc"bu } -getpass() { while : ; do pass rm -f "mutt-wizard-$title" >/dev/null 2>&1 - pass insert "mutt-wizard-$title" && break; done ;} +getpass() { while : ; do pass rm -f "$pass_prefix$title" >/dev/null 2>&1 + pass insert "$pass_prefix$title" && break; done ;} formatShortcut() { \ while read -r data; do { echo "macro index,pager g$1 \"$data\" \"go to $2\" # mw-autogenerated" -- cgit v1.2.3 From a60f5e7fb6609cb8d6c9bd6f32e20c7d744fd0fd Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 6 Oct 2020 11:42:28 -0400 Subject: some simplifications and soydevery removed --- bin/mw | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index ca090c3..3936b16 100755 --- a/bin/mw +++ b/bin/mw @@ -23,6 +23,7 @@ muttrc="$muttdir/muttrc" msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" msmtplog="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/msmtp.log" ssltype="IMAPS" # This is later changed to `None` later in the script if using Protonmail +MARKER="# mw-autogenerated" alias mbsync='mbsync -c "$mbsyncrc"' for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/" @@ -208,9 +209,9 @@ EOF echo "$mbsync_profile" >> "$mbsyncrc" notmuchauto [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" && echo "muttrc created." - ! grep "^source.*mutt-wizard.muttrc" "$muttrc" >/dev/null && echo "source $mwconfig # mw-autogenerated" >> "$muttrc" - ! grep "^source.*.muttrc" "$muttrc" | grep -v "$mwconfig" >/dev/null && echo "source $accdir/$idnum-$title.muttrc # mw-autogenerated" >> "$muttrc" - echo "macro index,pager i$idnum 'source $accdir/$idnum-$title.muttrc!;' \"switch to $fulladdr\" # mw-autogenerated" >> "$muttrc" + ! grep "^source.*mutt-wizard.muttrc" "$muttrc" >/dev/null && echo "source $mwconfig $MARKER" >> "$muttrc" + ! grep "^source.*.muttrc" "$muttrc" | grep -v "$mwconfig" >/dev/null && echo "source $accdir/$idnum-$title.muttrc $MARKER" >> "$muttrc" + echo "macro index,pager i$idnum 'source $accdir/$idnum-$title.muttrc!;' \"switch to $fulladdr\" $MARKER" >> "$muttrc" } protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" @@ -221,11 +222,14 @@ protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" getpass() { while : ; do pass rm -f "mutt-wizard-$title" >/dev/null 2>&1 pass insert "mutt-wizard-$title" && break; done ;} -formatShortcut() { \ - while read -r data; do { echo "macro index,pager g$1 \"$data\" \"go to $2\" # mw-autogenerated" - echo "macro index,pager M$1 \";$data\" \"move mail to $2\" # mw-autogenerated" - echo "macro index,pager C$1 \";$data\" \"copy mail to $2\" # mw-autogenerated"; } >> "$accdir/$idnum-$title.muttrc" - done ;} +formatShortcut() { toappend="$toappend +macro index,pager g$1 \"=$3\" \"go to $2\" $MARKER +macro index,pager M$1 \";=$3\" \"move mail to $2\" $MARKER +macro index,pager C$1 \";=$3\" \"copy mail to $2\" $MARKER" >> "$accdir/$idnum-$title.muttrc" +} + +setBox() { toappend="$toappend +set $1 = \"+$2\" $MARKER" ;} tryconnect() { mkdir -p "$maildir/$title" if mailboxes="$(mbsync -l "$title" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then @@ -239,25 +243,23 @@ tryconnect() { mkdir -p "$maildir/$title" fi ;} finalize() { \ - boxes="$(find "$maildir/$title/" -mindepth 1 -type d | sed "s/\ /\\\ /g;s/^.*\//=/;/=\(cur\|new\|tmp\)$/d")" + boxes="$(find "$maildir/$title/" -mindepth 1 -type d | sed "s/\ /\\\ /g;s/^.*\///;/\(cur\|new\|tmp\)$/d")" [ -z "$boxes" ] && printf "\033[31mNo local mailboxes have been detected for %s.\033[0m\\nThis means that mbsync has not been successfully run.\\nRun mbsync, and if it has an error, be sure to check your password and server settings manually if needbe.\\n" "$title" && return printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n" - spoolfile=$(echo "$boxes" | grep -i -m 1 inbox | sed 's/=/+/g') - record=$(echo "$boxes" | grep -i -m 1 sent | sed 's/=/+/g') - postponed=$(echo "$boxes" | grep -i -m 1 draft | sed 's/=/+/g') - trash=$(echo "$boxes" | grep -i -m 1 trash | sed 's/=/+/g') - sed -ibu "/^mailboxes\|^set record\|^set postponed\|^set trash\|^set spoolfile/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu" - { echo "set spoolfile = \"$spoolfile\""; echo "set record = \"$record\""; echo "set postponed = \"$postponed\""; echo "set trash = \"$trash\""; } >> "$accdir/$idnum-$title.muttrc" - echo "mailboxes $(echo "$boxes" | sed -e "s/^\|$/\"/g" | tr "\n" " ")" >> "$accdir/$idnum-$title.muttrc" + sed -ibu "/$MARKER/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu" + toappend="mailboxes $(echo "$boxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' )" + for x in $boxes; do + case $x in + *[Ii][Nn][Bb][Oo][Xx]*) formatShortcut i inbox "$x"; setBox spoolfile "$x" ;; + *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; + *[Dd][Rr][Aa][Ff][Tt][Ss]*) setBox postponed "$x"; formatShortcut d drafts "$x" ;; + *[Tt][Rr][Aa][Ss][Hh]*|*[Jj][Uu][Nn][Kk]*) formatShortcut t trash "$x"; setBox trash "$x" ;; + *[Aa][Rr][Cc][Hh][Ii][Vv][Ee]*) formatShortcut a archive "$x" ;; + *[Ss][Pp][Aa][Mm]*) formatShortcut S spam "$x" ;; + esac + done printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n" - sed -ibu "/# mw-autogenerated/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu" - echo "$boxes" | grep -i inbox | head -n 1 | formatShortcut i inbox - echo "$boxes" | grep -i sent | head -n 1 | formatShortcut s sent - echo "$boxes" | grep -i draft | head -n 1 | formatShortcut d drafts - echo "$boxes" | grep -i trash | head -n 1 | formatShortcut t trash - echo "$boxes" | grep -i spam | head -n 1 | formatShortcut S spam - echo "$boxes" | grep -i junk | head -n 1 | formatShortcut j junk - echo "$boxes" | grep -i archive | head -n 1 | formatShortcut a archive + echo "$toappend" >> "$accdir/$idnum-$title.muttrc" [ "$accounttype" = "offline" ] && printf "All done.\\n\033[33mYou should now be able to run \`\033[32mmbsync %s\033[33m\` to begin to download your mail.\033[0m\\n" "$title" command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" return 0 @@ -293,7 +295,7 @@ asktype() { while : ; do purge() { confirm "delete all account data" || exit rm -rf "$mbsyncrc" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$cachedir" echo "All configs and account settings have been purged." - sed -ibu "/\# mw-autogenerated/d" "$muttrc" ; rm -f "$muttrc"bu + sed -ibu "/$MARKER/d" "$muttrc" ; rm -f "$muttrc"bu } syncwrapper() { mbsync "${1:--a}" & -- cgit v1.2.3 From 8f45a05115732d601551835236b5ba6c46cd4eca Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 8 Oct 2020 18:13:15 -0400 Subject: begin work for 3.0 --- bin/mw | 299 ++++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 185 insertions(+), 114 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index e44d580..e23e5a1 100755 --- a/bin/mw +++ b/bin/mw @@ -1,5 +1,20 @@ #!/bin/sh +debug() { + echo "fulladdr: $fulladdr" + echo "login: $login" + echo "title: $title" + echo "imap: $imap" + echo "iport: $iport" + echo "smtp: $smtp" + echo "sport: $sport" + echo "proton: $proton" + echo "tls: $tls" + echo "force: $force" + echo "online: $online" + echo "action: $action" +} + command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" [ -z ${PASSWORD_STORE_DIR+x} ] && PASSWORD_STORE_DIR="$HOME/.password-store" [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && @@ -10,7 +25,7 @@ command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" ! command -v mbsync >/dev/null && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit prefix="/usr/local" -pass_prefix="mutt-wizard-" +pass_prefix="mw-" muttdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" # Main mutt config location accdir="$muttdir/accounts" # Directory for account settings maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" # Location of mail storage @@ -46,7 +61,7 @@ logfile $msmtplog " msmtp_profile="account $title host $smtp -port $sport +port ${sport:-587} from $fulladdr user $login passwordeval \"pass $pass_prefix$title\" @@ -54,7 +69,7 @@ $starttlsoff " mbsync_profile="IMAPStore $title-remote Host $imap -Port $iport +Port ${iport:-993} User $login PassCmd \"pass $pass_prefix$title\" AuthMechs LOGIN @@ -79,7 +94,7 @@ ExpireUnread no # End profile " -if [ "$accounttype" = "offline" ]; then +if [ -z "${online+x}" ]; then mutt_profile="# vim: filetype=neomuttrc # muttrc file for account $title set realname = \"$realname\" @@ -106,7 +121,7 @@ set realname = \"$realname\" set from = \"$fulladdr\" set sendmail = \"msmtp -a $title\" alias me $realname <$fulladdr> -set folder = \"imaps://$login@$imap:$iport\" +set folder = \"imaps://$login@$imap:${iport:-993}\" set imap_user = \"$login\" set header_cache = $cachedir/$title/headers set message_cachedir = $cachedir/$title/bodies @@ -127,92 +142,94 @@ fi printf "DONE.\\n" } +parsedomains(){ serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" + + [ -z "$serverinfo" ] && + serverinfo="$(grep "$(echo "${fulladdr#*@}" | sed "s/\.[^\.]*$/\.\\\*/")" "$muttshare/domains.csv" 2>/dev/null)" + + IFS=, read -r service imapsugg iportsugg smtpsugg sportsugg </dev/null; do - printf "That is not a valid \033[31memail address\033[0m, please retype the desired email.\\n\\nEmail: \033[36m\t" + [ -z "$fulladdr" ] && echo "Give the full email address to add:" && + read -r fulladdr + + while ! echo "$fulladdr" | grep -qE "$emailre"; do + echo "\`$fulladdr\` is not a valid email address. Please retype the address:" read -r fulladdr - printf "\033[0m" done - domain="$(echo "$fulladdr" | sed "s/.*@//")" - search_query=$domain - case "$domain" in - protonmail.com|protonmail.ch|pm.me) - search_query='protonmail.com' ;; - *) - while : ; do - printf "\nIs your email hosted with Protonmail? [yes/no] " - read -r is_protonmail - case $is_protonmail in - [Yy][Ee][Ss]) search_query='protonmail.com' && break;; - [Nn][Oo]) break;; - *) printf 'Please answer Yes or No' - esac; done; - esac - printf "\\nSearching for \033[32m%s\033[0m in \033[34m\`domains.csv\`\033[0m..." "$domain" - serverinfo="$(grep "^$search_query" "$muttshare/domains.csv" 2>/dev/null)" - if [ -z "$serverinfo" ]; then - search_query=$(echo "$search_query" | sed "s/\.[^\.]*$/\.\\\*/") - serverinfo="$(grep "^$search_query" "$muttshare/domains.csv" 2>/dev/null)" - fi - if [ -z "$serverinfo" ]; then - printf "Your email domain is not in mutt-wizard's database yet.\\nmutt-wizard will still autoconfigure everything, but you will have to manually type in your service's IMAP and SMTP server information.\\nYou can usually quickly find this by internet searching for it.\\n" - printf "Insert the IMAP server for your email provider (excluding the port number)\\n\033[36m\t" - read -r imap - printf "\033[0mWhat is your server's IMAP port number? (Usually something like 993)\\n\033[36m\t" - read -r iport - printf "\033[0mInsert the SMTP server for your email provider (excluding the port number)\\n\033[36m\t" - read -r smtp - printf "\033[0mWhat is your server's SMTP port number? (Usually 587 or 465)\\n\033[36m\t" - read -r sport - printf "\033[0m\\nGreat! If you want to be helpful, copy the line below and you can add it to the \`domains.csv\` file on Github.\\nThis will make things easier for others who use your email provider.\\n\\n%s,%s,%s,%s,%s\\n\\nAlthough be sure to test to see if these settings work first! ;-)\\n" "$domain" "$imap" "$iport" "$smtp" "$sport" - else - IFS=, read -r service imap iport smtp sport </dev/null || ls "$accdir"/[0-9]"-$title.muttrc" >/dev/null 2>&1; do - printf "\033[31mTry again\033[0m. Pick a nickname that is one word only including lowercase letters and _ or - and that you have \033[1mnot\033[0m used before.\\n\tAccount name: \033[36m\t" - read -r title - printf "\033[0m" - done - printf "If your account has a special username different from your address, insert it now. Otherwise leave this prompt totally blank.\\n\033[34mMost accounts will not have a separate login, so you should probably leave this blank.\033[0m\\n\tLogin(?): \033[36m" - read -r login - printf "\033[0m" - [ -z "$login" ] && login="$fulladdr" - [ "$accounttype" = "offline" ] && printf "If you want to limit the number of messages kept offline to a number, enter that number below. If you do not want to limit your mail and would like \`mbsync\` to sync all mail, press enter without typing a number.\\n\t" && read -r maxmes - echo "$maxmes" | grep "[1-9]" >/dev/null || maxmes="0" + + [ -z "$realname" ] && echo "Give the name you would like to be identified by on the email account:" && + read -r realname + + title="$fulladdr" + #while ! echo "$title" | grep -q "$namere" || ls "$accdir"/[0-9]"-$title.muttrc" >/dev/null 2>&1; do + #printf "\033[31mTry again\033[0m. Pick a nickname that is one word only including lowercase letters and _ or - and that you have \033[1mnot\033[0m used before.\\n\tAccount name: \033[36m\t" + #read -r title + #printf "\033[0m" + #done + + [ -z "$login" ] && echo "Give the account log-on/username for this address:" && read -r login + login="${login:-$fulladdr}" + + + + #case "$service" in + #gmail.com) printf "\033[31mREMEMBER: Gmail users must enable \"less secure\" (third-party) applications first for the sync to work:\\nhttps://support.google.com/accounts/answer/6010255\\n\033[0m" ;; + #protonmail.ch|protonmail.com|pm.me) printf "\033[31mREMEMBER: Protonmail users must install and configure Protonmail Bridge first for the sync to work:\\nhttps://protonmail.com/bridge/\\n\033[0m" && ssltype="None" ;; + #esac + getpass +} + + +writeinfo() { + # Insert account information into variables. getprofiles - mkdir -p "$muttdir" "$accdir" "$cachedir/$title/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" + + # Create required directories. + mkdir -p "$muttdir" "$accdir" "$cachedir/$title/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$title" + + # Get accounts and find the first missing account number (max. 9). getaccounts - for x in $(seq 1 9); do echo "$accounts" | grep "$x" >/dev/null 2>&1 || { export idnum="$x"; break ;}; done + for x in $(seq 1 9); do echo "$accounts" | grep -q "$x" || { export idnum="$x"; break ;}; done + + # Create msmtprc file if not present. [ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc" + + # Add account msmtp settings. echo "$msmtp_profile" >> "$msmtprc" + + # On Ubuntu/Debian, a link is needed since they use an older version. command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null - case "$service" in - protonmail.ch|protonmail.com|pm.me) protonfinger || return 1 ;; - esac + + # Create the individual mutt config file for the account. echo "$mutt_profile" > "$accdir/$idnum-$title.muttrc" + + # Create the mbsync config file. mkdir -p "${mbsyncrc%/*}" echo "$mbsync_profile" >> "$mbsyncrc" + + # Create a notmuch config file if not present already. notmuchauto + + # Create a basic muttrc is not present and source the mutt-wizard files + # and add the shortcuts to the account. [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" && echo "muttrc created." - ! grep "^source.*mutt-wizard.muttrc" "$muttrc" >/dev/null && echo "source $mwconfig $MARKER" >> "$muttrc" - ! grep "^source.*.muttrc" "$muttrc" | grep -v "$mwconfig" >/dev/null && echo "source $accdir/$idnum-$title.muttrc $MARKER" >> "$muttrc" + ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig $MARKER" >> "$muttrc" + ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$title.muttrc $MARKER" >> "$muttrc" echo "macro index,pager i$idnum 'source $accdir/$idnum-$title.muttrc!;' \"switch to $fulladdr\" $MARKER" >> "$muttrc" + } protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" @@ -225,18 +242,23 @@ getpass() { while : ; do pass rm -f "$pass_prefix$title" >/dev/null 2>&1 formatShortcut() { toappend="$toappend macro index,pager g$1 \"=$3\" \"go to $2\" $MARKER + getpass macro index,pager M$1 \";=$3\" \"move mail to $2\" $MARKER + getpass macro index,pager C$1 \";=$3\" \"copy mail to $2\" $MARKER" >> "$accdir/$idnum-$title.muttrc" } setBox() { toappend="$toappend set $1 = \"+$2\" $MARKER" ;} -tryconnect() { mkdir -p "$maildir/$title" +getboxes() { [ -n "${force+x}" ] && mailboxes="INBOX +Drafts +Junk +Sent +Archive" && return 0 if mailboxes="$(mbsync -l "$title" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then [ "$accounttype" = "online" ] && sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu printf "\033[32mMailboxes detected.\033[0m\\n" - echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$title/{}" return 0 else printf "\033[31m\033[31mLog-on not successful.\033[0m\\nIt seems that either you inputted the wrong password or server settings, or there are other requirements for your account out of the control of mutt-wizard.\\n" @@ -244,12 +266,17 @@ tryconnect() { mkdir -p "$maildir/$title" fi ;} finalize() { \ - boxes="$(find "$maildir/$title/" -mindepth 1 -type d | sed "s/\ /\\\ /g;s/^.*\///;/\(cur\|new\|tmp\)$/d")" - [ -z "$boxes" ] && printf "\033[31mNo local mailboxes have been detected for %s.\033[0m\\nThis means that mbsync has not been successfully run.\\nRun mbsync, and if it has an error, be sure to check your password and server settings manually if needbe.\\n" "$title" && return + + # Create the required mailbox structure. + echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$title/{}" + printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n" + sed -ibu "/$MARKER/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu" - toappend="mailboxes $(echo "$boxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' )" - for x in $boxes; do + + toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' )" + + for x in $mailboxes; do case $x in *[Ii][Nn][Bb][Oo][Xx]*) formatShortcut i inbox "$x"; setBox spoolfile "$x" ;; *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; @@ -259,15 +286,19 @@ finalize() { \ *[Ss][Pp][Aa][Mm]*) formatShortcut S spam "$x" ;; esac done - printf "Setting up your keyboard shortcuts for jumping between mailboxes...\\n" + echo "$toappend" >> "$accdir/$idnum-$title.muttrc" - [ "$accounttype" = "offline" ] && printf "All done.\\n\033[33mYou should now be able to run \`\033[32mmbsync %s\033[33m\` to begin to download your mail.\033[0m\\n" "$title" + + [ -z "${online+x}" ] && printf "All done.\\n\033[33mYou should now be able to run \`\033[32mmbsync %s\033[33m\` to begin to download your mail.\033[0m\\n" "$title" + + # Create a urlview config file if non-existent. command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" + return 0 } -confirm() { printf "Do you want to %s? [yes/N]\\n\t" "$@" && read -r input && ! echo "$input" | grep -i "^yes$" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 - printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -i "^yes$" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 +confirm() { printf "Do you want to %s? [yes/N]\\n\t" "$@" && read -r input && ! echo "$input" | grep -qi "^yes$" && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 + printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -qi "^yes$" && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 return 0 ;} pick() { printf "Select an accounts to %s:\\n" "$1" @@ -284,21 +315,6 @@ delete() { sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; sed -ibu "/account $title/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu } -asktype() { while : ; do - printf "Do you want to keep your mail for this account offline with mbsync? [yes/no]\\n\t" - read -r offnot - case "$offnot" in - [Yy][Ee][Ss]) accounttype="offline" && break ;; - [Nn][Oo]) accounttype="online" && break ;; - *) echo "Write out either yes or no completely. Try again or press ctrl-c to quit." ;; - esac; done ;} - -purge() { confirm "delete all account data" || exit - rm -rf "$mbsyncrc" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$cachedir" - echo "All configs and account settings have been purged." - sed -ibu "/$MARKER/d" "$muttrc" ; rm -f "$muttrc"bu -} - syncwrapper() { mbsync "${1:--a}" & ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null wait @@ -306,6 +322,12 @@ syncwrapper() { mbsync "${1:--a}" & notmuch new } +purge() { confirm "delete all account data" || exit + rm -rf "$mbsyncrc" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$cachedir" + echo "All configs and account settings have been purged." + sed -ibu "/$MARKER/d" "$muttrc" ; rm -f "$muttrc"bu +} + notmuchauto() { \ [ -z "$NOTMUCH_CONFIG" ] && NOTMUCH_CONFIG="$HOME/.notmuch-config" [ -f "$NOTMUCH_CONFIG" ] && return 0 @@ -327,26 +349,75 @@ gpg_path=$GPG" trap 'echo -e "\033[0m\n"; exit' INT ABRT -case "$1" in - ls) list ;; - add) asktype && askinfo && tryconnect && finalize || delete ;; - pass) pick "change the password of" && getpass ;; - delete) pick delete && confirm "delete the \`$title\` profile" && delete ;; - sync) syncwrapper "$2" ;; - purge) purge ;; +setaction() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then + echo "Running $1 with $action..." + echo "Incompatible options given. Only one action may be specified per run." + return 1 + else + action="$1" + fi; } + +while getopts "gbpPlhdYD:y:i:I:s:S:u:a:" o; do case "${o}" in + l) setaction list || exit 1 ;; + p) setaction pass || exit 1 ;; + d) setaction delete || exit 1 ;; + D) setaction delete || exit 1 ; title="$OPTARG" ;; + y) setaction sync || exit 1 ; title="$OPTARG" ;; + Y) setaction sync || exit 1 ;; + + a) setaction add || exit 1 ; fulladdr="$OPTARG" ;; + i) setaction add || exit 1 ; imap="$OPTARG" ;; + I) setaction add || exit 1 ; iport="$OPTARG" ;; + s) setaction add || exit 1 ; smtp="$OPTARG" ;; + S) setaction add || exit 1 ; sport="$OPTARG" ;; + u) setaction add || exit 1 ; login="$OPTARG" ;; + + o) setaction add || exit 1 ; online=True ;; + b) setaction add || exit 1 ; force=True ;; + P) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." + proton=True + imap="127.0.0.1" + iport=1143 + smtp="127.0.0.1" + sport=1025 + setaction add || exit 1 + ;; + + g) debug ;; + *) cat << EOF mw: mutt-wizard, auto-configure email accounts for mutt including downloadable mail with \`isync\`. -Allowed options: - add Add and autoconfigure an email address (9 max.) - ls List configured accounts - delete Pick an account to delete - purge Delete all accounts and settings - sync Syncs mail and updates notmuch database - all else Print this message +Main actions: + -a your@email.com Add an email address + -d Remove an already added address + -D nameofaccount Force remove account without confirmation + -l List email addresses configured + -y nameofaccount Sync mail for account by name + -Y Sync mail for all accounts + +Options allowed with -a: + -u Account login name if not full address. + -i IMAP server address + -I IMAP server port + -s SMTP server address + -S SMTP server port + -p Install for a Protonmail account. + -o Configure address, but keep mail online. + -b Assume typical English mailboxes without attempting log-on. NOTE: Once at least one account is added, you can run \`mbsync -a\` to begin downloading mail. EOF +;; +esac done + +case "$action" in + list) list ;; + add) askinfo && writeinfo && getboxes && finalize || delete ;; + pass) pick "change the password of" && getpass ;; + delete) pick delete && confirm "delete the \`$title\` profile" && delete ;; + sync) syncwrapper $title ;; + purge) purge ;; esac -- cgit v1.2.3 From 601d496fdf0df4d2f48877c545f0eee60632a9b2 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 9 Oct 2020 09:46:50 -0400 Subject: 3.0 release --- README.md | 31 +++++++-- bin/mw | 232 +++++++++++++++++++++++++++----------------------------------- mw.1 | 70 ++++++++++++++----- 3 files changed, 178 insertions(+), 155 deletions(-) (limited to 'bin/mw') diff --git a/README.md b/README.md index 0da14f4..0a7629f 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,31 @@ User of Arch-based distros can also install mutt-wizard from the AUR as [mutt-wi The mutt-wizard is run with the command `mw`. Once everything is setup, you'll use `neomutt` to access your mail. -- `mw add` -- add a new email account -- `mw ls` -- list existing accounts -- `mw pass` -- revise an account's password -- `mw delete` -- delete an added account -- `mw sync` -- sync all mail accounts and update notmuch database -- `mw purge` -- delete all accounts and settings +- `mw -a you@email.com` -- add a new email account +- `mw -l` -- list existing accounts +- `mw -y your@email.com` -- sync an email account +- `my -Y` -- sync all configured email accounts +- `mw -d` -- choose an account to delete +- `mw -D your@email.com` -- delete account settings without confirmation +- `pass edit mw-your@email.com` -- revise an account's password + +### Options usable when adding an account + +#### Providing arguments + +- `-u` -- Give an account username if different from the email address. If you use my [emailwiz](https://github.com/lukesmithxyz/emailwiz), give your username with this option. Not necessary for other accounts. +- `-n` -- A real name to be used by the account. Put in quotations if multiple words +- `-i` -- IMAP server address +- `-I` -- IMAP server port (otherwise assumed to be 993) +- `-s` -- SMTP server address +- `-S` -- SMTP server port (otherwise assumed to be 587) +- `-m` -- Maximum number of emails to be kept offline. No maximum is default functionality. + +#### General Settings + +- `-p` -- Add a Protonmail account +- `-f` -- Assume mailbox names and force account configuration without connecting online at all. +- `-o` -- Configure mutt for an account, but do not keep mail offline. ## Dependencies diff --git a/bin/mw b/bin/mw index e23e5a1..387747a 100755 --- a/bin/mw +++ b/bin/mw @@ -1,20 +1,5 @@ #!/bin/sh -debug() { - echo "fulladdr: $fulladdr" - echo "login: $login" - echo "title: $title" - echo "imap: $imap" - echo "iport: $iport" - echo "smtp: $smtp" - echo "sport: $sport" - echo "proton: $proton" - echo "tls: $tls" - echo "force: $force" - echo "online: $online" - echo "action: $action" -} - command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" [ -z ${PASSWORD_STORE_DIR+x} ] && PASSWORD_STORE_DIR="$HOME/.password-store" [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && @@ -22,7 +7,6 @@ command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init \`.\\nIf you don't have a GPG public private key pair, run \`%s --full-gen-key\` first.\\n" "$GPG" exit } -! command -v mbsync >/dev/null && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit prefix="/usr/local" pass_prefix="mw-" @@ -38,7 +22,6 @@ cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard" muttrc="$muttdir/muttrc" msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" msmtplog="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/msmtp.log" -ssltype="IMAPS" # This is later changed to `None` later in the script if using Protonmail MARKER="# mw-autogenerated" alias mbsync='mbsync -c "$mbsyncrc"' @@ -47,63 +30,63 @@ do [ -f "$x" ] && sslcert="$x" && break done || { echo "CA Certificate not found. Please install one or link it to /etc/ssl/certs/ca-certificates.crt" && exit 1 ;} -getaccounts() { accounts="$(find "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\..*//" | sort -n)" ;} +getaccounts() { accounts="$(find "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} + list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" ;} getprofiles() { \ unset msmtp_header msmtp_profile mutt_profile mbsync_profile - printf "Creating profiles for \`%s\`..." "$title" msmtp_header="defaults auth on tls on tls_trust_file $sslcert logfile $msmtplog " -msmtp_profile="account $title +msmtp_profile="account $fulladdr host $smtp port ${sport:-587} from $fulladdr user $login -passwordeval \"pass $pass_prefix$title\" +passwordeval \"pass $pass_prefix$fulladdr\" $starttlsoff " -mbsync_profile="IMAPStore $title-remote +mbsync_profile="IMAPStore $fulladdr-remote Host $imap Port ${iport:-993} User $login -PassCmd \"pass $pass_prefix$title\" +PassCmd \"pass $pass_prefix$fulladdr\" AuthMechs LOGIN -SSLType $ssltype +SSLType ${ssltype:-IMAPS} CertificateFile $sslcert -MaildirStore $title-local +MaildirStore $fulladdr-local Subfolders Verbatim -Path ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$title/ -Inbox ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$title/INBOX +Path ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/ +Inbox ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/INBOX Flatten . -Channel $title +Channel $fulladdr Expunge Both -Master :$title-remote: -Slave :$title-local: +Master :$fulladdr-remote: +Slave :$fulladdr-local: Patterns * !\"[Gmail]/All Mail\" Create Both SyncState * -MaxMessages $maxmes +MaxMessages ${maxmes:-0} ExpireUnread no # End profile " if [ -z "${online+x}" ]; then mutt_profile="# vim: filetype=neomuttrc -# muttrc file for account $title +# muttrc file for account $fulladdr set realname = \"$realname\" set from = \"$fulladdr\" -set sendmail = \"msmtp -a $title\" +set sendmail = \"msmtp -a $fulladdr\" alias me $realname <$fulladdr> -set folder = \"$maildir/$title\" -set header_cache = $cachedir/$title/headers -set message_cachedir = $cachedir/$title/bodies +set folder = \"$maildir/$fulladdr\" +set header_cache = $cachedir/$fulladdr/headers +set message_cachedir = $cachedir/$fulladdr/bodies set mbox_type = Maildir bind index,pager gg noop @@ -111,21 +94,21 @@ bind index,pager g noop bind index,pager M noop bind index,pager C noop bind index gg first-entry -macro index o \"mbsync -V $title\" \"run mbsync to sync $title\" +macro index o \"mbsync -V $fulladdr\" \"run mbsync to sync $fulladdr\" unmailboxes * " else mutt_profile="# vim: filetype=neomuttrc -# muttrc file for account $title +# muttrc file for account $fulladdr set realname = \"$realname\" set from = \"$fulladdr\" -set sendmail = \"msmtp -a $title\" +set sendmail = \"msmtp -a $fulladdr\" alias me $realname <$fulladdr> set folder = \"imaps://$login@$imap:${iport:-993}\" set imap_user = \"$login\" -set header_cache = $cachedir/$title/headers -set message_cachedir = $cachedir/$title/bodies -set imap_pass = \"\`pass $pass_prefix$title\`\" +set header_cache = $cachedir/$fulladdr/headers +set message_cachedir = $cachedir/$fulladdr/bodies +set imap_pass = \"\`pass $pass_prefix$fulladdr\`\" set mbox_type = Maildir set ssl_starttls = yes @@ -142,7 +125,10 @@ fi printf "DONE.\\n" } -parsedomains(){ serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" +parsedomains(){ \ + # Parses the domains.csv file for server information and sets + # the required variables unless overridden by the user. + serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" [ -z "$serverinfo" ] && serverinfo="$(grep "$(echo "${fulladdr#*@}" | sed "s/\.[^\.]*$/\.\\\*/")" "$muttshare/domains.csv" 2>/dev/null)" @@ -156,39 +142,42 @@ EOF iport="${iport:-$iportsugg}" } +delete() { if [ -z "${fulladdr+x}" ]; then + echo "Select the account your would like to delete (by number):" + list + read -r input + match="^$input:" + else + match=" $fulladdr$" + getaccounts + fi + + fulladdr="$(echo "$accounts" | grep "$match" | cut -f2 -d' ')" + + [ -z "$fulladdr" ] && echo "Invalid account name given." && return 1 + + sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -rf "$mbsyncrc"bu + rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc" + sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu + sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu + } + askinfo() { \ [ -z "$fulladdr" ] && echo "Give the full email address to add:" && read -r fulladdr - while ! echo "$fulladdr" | grep -qE "$emailre"; do echo "\`$fulladdr\` is not a valid email address. Please retype the address:" read -r fulladdr done - - # If we don't have either the IMAP or SMTP servers, look for them and ports. { [ -z "$imap" ] || [ -z "$smtp" ] ;} && parsedomains + [ -z "$imap" ] && echo "Give your email server's IMAP address (excluding the port number):" && + read -r imap + [ -z "$smtp" ] && echo "Give your email server's SMTP address (excluding the port number):" && + read -r smtp [ "$sport" = 465 ] && starttlsoff="tls_starttls off" - [ -z "$realname" ] && echo "Give the name you would like to be identified by on the email account:" && read -r realname - - title="$fulladdr" - #while ! echo "$title" | grep -q "$namere" || ls "$accdir"/[0-9]"-$title.muttrc" >/dev/null 2>&1; do - #printf "\033[31mTry again\033[0m. Pick a nickname that is one word only including lowercase letters and _ or - and that you have \033[1mnot\033[0m used before.\\n\tAccount name: \033[36m\t" - #read -r title - #printf "\033[0m" - #done - - [ -z "$login" ] && echo "Give the account log-on/username for this address:" && read -r login login="${login:-$fulladdr}" - - - - #case "$service" in - #gmail.com) printf "\033[31mREMEMBER: Gmail users must enable \"less secure\" (third-party) applications first for the sync to work:\\nhttps://support.google.com/accounts/answer/6010255\\n\033[0m" ;; - #protonmail.ch|protonmail.com|pm.me) printf "\033[31mREMEMBER: Protonmail users must install and configure Protonmail Bridge first for the sync to work:\\nhttps://protonmail.com/bridge/\\n\033[0m" && ssltype="None" ;; - #esac - getpass } @@ -198,7 +187,7 @@ writeinfo() { getprofiles # Create required directories. - mkdir -p "$muttdir" "$accdir" "$cachedir/$title/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$title" + mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr" # Get accounts and find the first missing account number (max. 9). getaccounts @@ -214,7 +203,7 @@ writeinfo() { command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null # Create the individual mutt config file for the account. - echo "$mutt_profile" > "$accdir/$idnum-$title.muttrc" + echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc" # Create the mbsync config file. mkdir -p "${mbsyncrc%/*}" @@ -227,26 +216,21 @@ writeinfo() { # and add the shortcuts to the account. [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" && echo "muttrc created." ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig $MARKER" >> "$muttrc" - ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$title.muttrc $MARKER" >> "$muttrc" - echo "macro index,pager i$idnum 'source $accdir/$idnum-$title.muttrc!;' \"switch to $fulladdr\" $MARKER" >> "$muttrc" - + ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc $MARKER" >> "$muttrc" + echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\" $MARKER" >> "$muttrc" } protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" - fingerprint="$(msmtp --serverinfo --host=127.0.0.1 --port=1025 --tls --tls-certcheck=off | grep SHA256: | sed 's/^.*: //')" - sed -ibu "s/account $title/&\ntls_trust_file\ntls_fingerprint $fingerprint/" "$msmtprc" ; rm -f "$msmtprc"bu -} + fingerprint="$(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | grep SHA256: | sed 's/^.*: //')" + sed -ibu "s/account $fulladdr/&\ntls_trust_file\ntls_fingerprint $fingerprint/" "$msmtprc" ; rm -f "$msmtprc"bu ;} -getpass() { while : ; do pass rm -f "$pass_prefix$title" >/dev/null 2>&1 - pass insert "$pass_prefix$title" && break; done ;} +getpass() { while : ; do pass rm -f "$pass_prefix$fulladdr" >/dev/null 2>&1 + pass insert "$pass_prefix$fulladdr" && break; done ;} formatShortcut() { toappend="$toappend macro index,pager g$1 \"=$3\" \"go to $2\" $MARKER - getpass macro index,pager M$1 \";=$3\" \"move mail to $2\" $MARKER - getpass -macro index,pager C$1 \";=$3\" \"copy mail to $2\" $MARKER" >> "$accdir/$idnum-$title.muttrc" -} +macro index,pager C$1 \";=$3\" \"copy mail to $2\" $MARKER" >> "$accdir/$idnum-$fulladdr.muttrc" ;} setBox() { toappend="$toappend set $1 = \"+$2\" $MARKER" ;} @@ -254,73 +238,54 @@ set $1 = \"+$2\" $MARKER" ;} getboxes() { [ -n "${force+x}" ] && mailboxes="INBOX Drafts Junk +Trash Sent Archive" && return 0 - if mailboxes="$(mbsync -l "$title" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then - [ "$accounttype" = "online" ] && sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu - printf "\033[32mMailboxes detected.\033[0m\\n" + if mailboxes="$(mbsync -l "$fulladdr" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then + [ "$accounttype" = "online" ] && sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu return 0 else + echo "$mailboxes" printf "\033[31m\033[31mLog-on not successful.\033[0m\\nIt seems that either you inputted the wrong password or server settings, or there are other requirements for your account out of the control of mutt-wizard.\\n" return 1 fi ;} -finalize() { \ - - # Create the required mailbox structure. - echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$title/{}" - - printf "Setting default mailboxes for your Inbox, Sent, Drafts and Trash in mutt...\\n" - - sed -ibu "/$MARKER/d" "$accdir/$idnum-$title.muttrc" ; rm -f "$accdir/$idnum-$title.muttrcbu" - +finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" + sed -ibu "/$MARKER/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu" toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' )" - for x in $mailboxes; do case $x in *[Ii][Nn][Bb][Oo][Xx]*) formatShortcut i inbox "$x"; setBox spoolfile "$x" ;; *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; *[Dd][Rr][Aa][Ff][Tt][Ss]*) setBox postponed "$x"; formatShortcut d drafts "$x" ;; - *[Tt][Rr][Aa][Ss][Hh]*|*[Jj][Uu][Nn][Kk]*) formatShortcut t trash "$x"; setBox trash "$x" ;; + *[Tt][Rr][Aa][Ss][Hh]*) formatShortcut t trash "$x"; setBox trash "$x" ;; + *[Jj][Uu][Nn][Kk]*) formatShortcut j junk "$x" ;; *[Aa][Rr][Cc][Hh][Ii][Vv][Ee]*) formatShortcut a archive "$x" ;; *[Ss][Pp][Aa][Mm]*) formatShortcut S spam "$x" ;; esac done - - echo "$toappend" >> "$accdir/$idnum-$title.muttrc" - - [ -z "${online+x}" ] && printf "All done.\\n\033[33mYou should now be able to run \`\033[32mmbsync %s\033[33m\` to begin to download your mail.\033[0m\\n" "$title" - - # Create a urlview config file if non-existent. + echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" + [ -z "${online+x}" ] && printf "\033[33mYou should now be able to run \`\033[32mw -y %s\033[33m\` to begin to download your mail.\033[0m\\n" "$fulladdr" command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" - - return 0 -} + return 0 ;} confirm() { printf "Do you want to %s? [yes/N]\\n\t" "$@" && read -r input && ! echo "$input" | grep -qi "^yes$" && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -qi "^yes$" && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 return 0 ;} -pick() { printf "Select an accounts to %s:\\n" "$1" +pick() { [ -n "${fulladdr+x}" ] && return 0 + echo "Select the account your would like to $1 (by number):" list read -r input - [ -z "$input" ] && return 1 - title="$(echo "$accounts" | grep "$input" | awk '{print $2}')" - [ -z "$title" ] && printf "Invalid response." && return 1 + fulladdr="$(echo "$accounts" | grep "^$input:" | cut -f2 -d' ')" + [ -z "$fulladdr" ] && echo "Invalid response." && return 1 return 0 ;} -delete() { sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ; rm -rf "$mbsyncrc"bu - rm -rf "${cachedir:?}/${title:?}" "$accdir/"[1-9]"-$title.muttrc" - sed -ibu "/[0-9]-$title.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu - sed -ibu "/account $title/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu - } - syncwrapper() { mbsync "${1:--a}" & ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null wait ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null - notmuch new -} + notmuch new ;} purge() { confirm "delete all account data" || exit rm -rf "$mbsyncrc" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$cachedir" @@ -357,48 +322,47 @@ setaction() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then action="$1" fi; } -while getopts "gbpPlhdYD:y:i:I:s:S:u:a:" o; do case "${o}" in +while getopts "fplhdYD:y:i:I:s:S:u:a:n:" o; do case "${o}" in l) setaction list || exit 1 ;; - p) setaction pass || exit 1 ;; d) setaction delete || exit 1 ;; - D) setaction delete || exit 1 ; title="$OPTARG" ;; - y) setaction sync || exit 1 ; title="$OPTARG" ;; + D) setaction delete || exit 1 ; fulladdr="$OPTARG" ;; + y) setaction sync || exit 1 ; fulladdr="$OPTARG" ;; Y) setaction sync || exit 1 ;; - a) setaction add || exit 1 ; fulladdr="$OPTARG" ;; i) setaction add || exit 1 ; imap="$OPTARG" ;; I) setaction add || exit 1 ; iport="$OPTARG" ;; s) setaction add || exit 1 ; smtp="$OPTARG" ;; S) setaction add || exit 1 ; sport="$OPTARG" ;; u) setaction add || exit 1 ; login="$OPTARG" ;; - + n) setaction add || exit 1 ; realname="$OPTARG" ;; + m) setaction add || exit 1 ; maxmes="$OPTARG" ;; o) setaction add || exit 1 ; online=True ;; - b) setaction add || exit 1 ; force=True ;; - P) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." + f) setaction add || exit 1 ; force=True ;; + p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." proton=True imap="127.0.0.1" - iport=1143 + iport="1143" smtp="127.0.0.1" - sport=1025 + sport="1025" + ssltype="None" + protonfinger setaction add || exit 1 ;; - - g) debug ;; - *) cat << EOF mw: mutt-wizard, auto-configure email accounts for mutt including downloadable mail with \`isync\`. Main actions: -a your@email.com Add an email address - -d Remove an already added address - -D nameofaccount Force remove account without confirmation -l List email addresses configured - -y nameofaccount Sync mail for account by name + -d Remove an already added address + -D your@email.com Force remove account without confirmation + -y your@email.com Sync mail for account by name -Y Sync mail for all accounts Options allowed with -a: -u Account login name if not full address. + -n "Real name" to be on the email account. -i IMAP server address -I IMAP server port -s SMTP server address @@ -409,15 +373,19 @@ Options allowed with -a: NOTE: Once at least one account is added, you can run \`mbsync -a\` to begin downloading mail. + +To chane an account's password, run \`pass edit ${pass_prefix}your@email.com\`. EOF +exit 1 ;; esac done +! command -v mbsync >/dev/null && [ -z "${force+x}" ] && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit + case "$action" in list) list ;; add) askinfo && writeinfo && getboxes && finalize || delete ;; - pass) pick "change the password of" && getpass ;; - delete) pick delete && confirm "delete the \`$title\` profile" && delete ;; - sync) syncwrapper $title ;; + delete) delete $fulladdr ;; + sync) syncwrapper $fulladdr ;; purge) purge ;; esac diff --git a/mw.1 b/mw.1 index 55ad43c..eb344b3 100644 --- a/mw.1 +++ b/mw.1 @@ -3,7 +3,9 @@ mw \- mutt-wizard \- autoconfigure email accounts for neomutt and isync .SH SYNOPSIS .B mw - +[ +.I OPTIONS +] .SH DESCRIPTION .B mw takes a user email account and sets up a terminal-based email interface for it with @@ -16,22 +18,58 @@ for sending mail, and also passwords automatically encrypted and stored with .B pass. .SH COMMANDS .TP -.B add -configure an email account +.B -a your@email.com +add an email address .TP -.B ls +.B -l list all email accounts configured by mutt-wizard .TP -.B delete -delete the configuration files for an already configured email account +.B -d +pick an already configured account and remove its configuration .TP -.B purge -totally purge all local mutt-wizard accounts +.B -D your@email.com +remove a configured account without confirmation .TP -.B sync -sync mail accounts then update notmuch database -.B mailsync -as often as you wish +.B -y your@email.com +download and upload mail for an email account +.TP +.B -Y +sync all email accounts +.SH OPTIONS FOR ADDING ACCOUNTS +These can be specified on the command line, otherwise, you will be prompted for what is necessary. mutt-wizard knows the IMAP/SMTP server information for most email providers, so specifying them is usually redundant. +.TP +.B -u billy +Account logon/username if required and different from email address. +.TP +.B -n Billy +Real name which will appear in emails. Should be put in quotes if multiple words. +.TP +.B -m number +Set a maximum number of messages to be stored offline. +.TP +.B -i +IMAP server address +.TP +.B -I +IMAP server port (assumed to be 993 if not specified) +.TP +.B -s +SMTP server address +.TP +.B -S +SMTP server port (assumed to be 587 if not specified) +.SH OTHER OPTIONS +.TP +.B -f +Force account creation and guess mailboxes without attempting to connect to server. Otherwise if connection cannot be made, the configured account settings will not be persistent. +.TP +.B -o +Create settings for an account to be used online only without mail syncing abilities. Without +.B -f +connection will still be attempted in setup to discover mailboxes. +.TP +.B -p +Add a Protonmail account. Protonmail Bridge must be installed and set up. .SH DETAILS .TP .B Mail location @@ -52,11 +90,9 @@ and can be edited by the user if needbe. Note that the mutt-wizard will also sou file. .TP .B Mail deletion -Neither -.B delete -or -.B purge -will delete downloaded mail for safety (and time)'s sake. If you want to delete downloaded mail, do so manually by removing it from the directory above. +mutt-wizard's delete action will delete configuration files and +.I not +downloaded mail for safety (and time)'s sake. If you want to delete downloaded mail, do so manually by removing it from the directory above. .TP .B Default settings The mutt-wizard has many default settings that focus on making it aesthetically pleasing and supplying more vim-like bindings. These can be found in -- cgit v1.2.3 From c08cfd53654bb3046502955c93399861b487c760 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sun, 11 Oct 2020 19:29:34 -0400 Subject: more --- bin/mw | 50 ++++++++++-------------------------------------- share/mutt-wizard.muttrc | 2 +- 2 files changed, 11 insertions(+), 41 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 387747a..6f4448f 100755 --- a/bin/mw +++ b/bin/mw @@ -94,7 +94,7 @@ bind index,pager g noop bind index,pager M noop bind index,pager C noop bind index gg first-entry -macro index o \"mbsync -V $fulladdr\" \"run mbsync to sync $fulladdr\" +macro index o \"mw -y $fulladdr\" \"run mbsync to sync $fulladdr\" unmailboxes * " else @@ -182,42 +182,31 @@ askinfo() { \ } -writeinfo() { - # Insert account information into variables. - getprofiles - - # Create required directories. - mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr" +writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr" # Get accounts and find the first missing account number (max. 9). getaccounts for x in $(seq 1 9); do echo "$accounts" | grep -q "$x" || { export idnum="$x"; break ;}; done - # Create msmtprc file if not present. + # Configure msmtprc for sending mail. [ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc" - - # Add account msmtp settings. echo "$msmtp_profile" >> "$msmtprc" - # On Ubuntu/Debian, a link is needed since they use an older version. command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null - # Create the individual mutt config file for the account. - echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc" - # Create the mbsync config file. mkdir -p "${mbsyncrc%/*}" echo "$mbsync_profile" >> "$mbsyncrc" - # Create a notmuch config file if not present already. - notmuchauto - - # Create a basic muttrc is not present and source the mutt-wizard files - # and add the shortcuts to the account. - [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" && echo "muttrc created." + # Create a muttrc for viewing mail. + echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc" + [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig $MARKER" >> "$muttrc" ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc $MARKER" >> "$muttrc" echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\" $MARKER" >> "$muttrc" + + # Create a notmuch config file if not present already. + notmuchauto } protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" @@ -269,30 +258,12 @@ finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" return 0 ;} -confirm() { printf "Do you want to %s? [yes/N]\\n\t" "$@" && read -r input && ! echo "$input" | grep -qi "^yes$" && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 - printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -qi "^yes$" && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 - return 0 ;} - -pick() { [ -n "${fulladdr+x}" ] && return 0 - echo "Select the account your would like to $1 (by number):" - list - read -r input - fulladdr="$(echo "$accounts" | grep "^$input:" | cut -f2 -d' ')" - [ -z "$fulladdr" ] && echo "Invalid response." && return 1 - return 0 ;} - syncwrapper() { mbsync "${1:--a}" & ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null wait ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null notmuch new ;} -purge() { confirm "delete all account data" || exit - rm -rf "$mbsyncrc" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$cachedir" - echo "All configs and account settings have been purged." - sed -ibu "/$MARKER/d" "$muttrc" ; rm -f "$muttrc"bu -} - notmuchauto() { \ [ -z "$NOTMUCH_CONFIG" ] && NOTMUCH_CONFIG="$HOME/.notmuch-config" [ -f "$NOTMUCH_CONFIG" ] && return 0 @@ -384,8 +355,7 @@ esac done case "$action" in list) list ;; - add) askinfo && writeinfo && getboxes && finalize || delete ;; + add) askinfo && getprofiles && writeinfo && getboxes && finalize || delete ;; delete) delete $fulladdr ;; sync) syncwrapper $fulladdr ;; - purge) purge ;; esac diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc index 57df579..de169db 100644 --- a/share/mutt-wizard.muttrc +++ b/share/mutt-wizard.muttrc @@ -80,7 +80,7 @@ set sidebar_width = 20 set sidebar_short_path = yes set sidebar_next_new_wrap = yes set mail_check_stats -set sidebar_format = '%B%?F? [%F]?%* %?N?%N/? %?S?%S?' +set sidebar_format = '%D%?F? [%F]?%* %?N?%N/? %?S?%S?' bind index,pager \Ck sidebar-prev bind index,pager \Cj sidebar-next bind index,pager \Co sidebar-open -- cgit v1.2.3 From 9fa021377427122c57e6a40813f7eb3fc4df18d3 Mon Sep 17 00:00:00 2001 From: zneix <44851575+zneix@users.noreply.github.com> Date: Mon, 12 Oct 2020 09:13:55 +0200 Subject: Fixed a typo in successful logon message It was a bit confusing when it said "use `w -y user@example.com` to sync your mail" --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 387747a..71ac332 100755 --- a/bin/mw +++ b/bin/mw @@ -265,7 +265,7 @@ finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur esac done echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" - [ -z "${online+x}" ] && printf "\033[33mYou should now be able to run \`\033[32mw -y %s\033[33m\` to begin to download your mail.\033[0m\\n" "$fulladdr" + [ -z "${online+x}" ] && printf "\033[33mYou should now be able to run \`\033[32mmw -y %s\033[33m\` to begin to download your mail.\033[0m\\n" "$fulladdr" command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" return 0 ;} -- cgit v1.2.3 From 317c36ca87bfff66316cce792d6a306ff1d1e05b Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 12 Oct 2020 09:05:46 -0400 Subject: more more --- bin/mw | 66 ++++++++++++++++++++++++++++++------------------------------------ 1 file changed, 30 insertions(+), 36 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index cb65be3..4a9970d 100755 --- a/bin/mw +++ b/bin/mw @@ -125,22 +125,18 @@ fi printf "DONE.\\n" } -parsedomains(){ \ - # Parses the domains.csv file for server information and sets - # the required variables unless overridden by the user. - serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" +parsedomains(){ serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" - [ -z "$serverinfo" ] && - serverinfo="$(grep "$(echo "${fulladdr#*@}" | sed "s/\.[^\.]*$/\.\\\*/")" "$muttshare/domains.csv" 2>/dev/null)" + [ -z "$serverinfo" ] && serverinfo="$(grep "$(echo "${fulladdr#*@}" | sed "s/\.[^\.]*$/\.\\\*/")" "$muttshare/domains.csv" 2>/dev/null)" - IFS=, read -r service imapsugg iportsugg smtpsugg sportsugg < "$msmtprc" @@ -205,8 +200,7 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_ ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc $MARKER" >> "$muttrc" echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\" $MARKER" >> "$muttrc" - # Create a notmuch config file if not present already. - notmuchauto + notmuchauto # Create a notmuch config file if not present already. } protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" @@ -283,9 +277,7 @@ synchronize_flags=true gpg_path=$GPG" echo "$nmbasic" > "$NOTMUCH_CONFIG" ;} -trap 'echo -e "\033[0m\n"; exit' INT ABRT - -setaction() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then +setact() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then echo "Running $1 with $action..." echo "Incompatible options given. Only one action may be specified per run." return 1 @@ -293,22 +285,24 @@ setaction() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then action="$1" fi; } +trap 'echo -e "\033[0m\n"; exit' INT ABRT + while getopts "fplhdYD:y:i:I:s:S:u:a:n:" o; do case "${o}" in - l) setaction list || exit 1 ;; - d) setaction delete || exit 1 ;; - D) setaction delete || exit 1 ; fulladdr="$OPTARG" ;; - y) setaction sync || exit 1 ; fulladdr="$OPTARG" ;; - Y) setaction sync || exit 1 ;; - a) setaction add || exit 1 ; fulladdr="$OPTARG" ;; - i) setaction add || exit 1 ; imap="$OPTARG" ;; - I) setaction add || exit 1 ; iport="$OPTARG" ;; - s) setaction add || exit 1 ; smtp="$OPTARG" ;; - S) setaction add || exit 1 ; sport="$OPTARG" ;; - u) setaction add || exit 1 ; login="$OPTARG" ;; - n) setaction add || exit 1 ; realname="$OPTARG" ;; - m) setaction add || exit 1 ; maxmes="$OPTARG" ;; - o) setaction add || exit 1 ; online=True ;; - f) setaction add || exit 1 ; force=True ;; + l) setact list || exit 1 ;; + d) setact delete || exit 1 ;; + D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; + y) setact sync || exit 1 ; fulladdr="$OPTARG" ;; + Y) setact sync || exit 1 ;; + a) setact add || exit 1 ; fulladdr="$OPTARG" ;; + i) setact add || exit 1 ; imap="$OPTARG" ;; + I) setact add || exit 1 ; iport="$OPTARG" ;; + s) setact add || exit 1 ; smtp="$OPTARG" ;; + S) setact add || exit 1 ; sport="$OPTARG" ;; + u) setact add || exit 1 ; login="$OPTARG" ;; + n) setact add || exit 1 ; realname="$OPTARG" ;; + m) setact add || exit 1 ; maxmes="$OPTARG" ;; + o) setact add || exit 1 ; online=True ;; + f) setact add || exit 1 ; force=True ;; p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." proton=True imap="127.0.0.1" @@ -317,7 +311,7 @@ while getopts "fplhdYD:y:i:I:s:S:u:a:n:" o; do case "${o}" in sport="1025" ssltype="None" protonfinger - setaction add || exit 1 + setact add || exit 1 ;; *) cat << EOF mw: mutt-wizard, auto-configure email accounts for mutt -- cgit v1.2.3 From ca6cbd54b82ceb0d7b4c0987dff2c2b3b30b15fe Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 12 Oct 2020 18:50:10 -0400 Subject: passwords can be given by commandline --- README.md | 1 + bin/mw | 14 +++++++++++--- mw.1 | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/README.md b/README.md index 0a7629f..10bdc1f 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ The mutt-wizard is run with the command `mw`. Once everything is setup, you'll u - `-s` -- SMTP server address - `-S` -- SMTP server port (otherwise assumed to be 587) - `-m` -- Maximum number of emails to be kept offline. No maximum is default functionality. +- `-x` -- Account password. You will be prompted for it otherwise. #### General Settings diff --git a/bin/mw b/bin/mw index 4a9970d..eeebe53 100755 --- a/bin/mw +++ b/bin/mw @@ -122,7 +122,6 @@ bind index gg first-entry unmailboxes * " fi - printf "DONE.\\n" } parsedomains(){ serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" @@ -156,6 +155,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc" sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu + pass rm -f "$pass_prefix$fulladdr" >/dev/null 2>&1 } askinfo() { \ @@ -174,9 +174,16 @@ askinfo() { \ [ -z "$realname" ] && echo "Give the name you would like to be identified by on the email account:" && read -r realname login="${login:-$fulladdr}" - getpass + if [ -n "${password+x}" ]; then + createpass + else + getpass + fi } +createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$pass_prefix$fulladdr" + "$GPG" -qer "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" "$PASSWORD_STORE_DIR/$pass_prefix$fulladdr" + rm -f "$PASSWORD_STORE_DIR/$pass_prefix$fulladdr" ;} writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr" @@ -287,7 +294,7 @@ setact() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then trap 'echo -e "\033[0m\n"; exit' INT ABRT -while getopts "fplhdYD:y:i:I:s:S:u:a:n:" o; do case "${o}" in +while getopts "fplhdYD:y:i:I:s:S:u:a:n:x:" o; do case "${o}" in l) setact list || exit 1 ;; d) setact delete || exit 1 ;; D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; @@ -303,6 +310,7 @@ while getopts "fplhdYD:y:i:I:s:S:u:a:n:" o; do case "${o}" in m) setact add || exit 1 ; maxmes="$OPTARG" ;; o) setact add || exit 1 ; online=True ;; f) setact add || exit 1 ; force=True ;; + x) setact add || exit 1 ; password="$OPTARG" ;; p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." proton=True imap="127.0.0.1" diff --git a/mw.1 b/mw.1 index eb344b3..3ed4d95 100644 --- a/mw.1 +++ b/mw.1 @@ -58,6 +58,9 @@ SMTP server address .TP .B -S SMTP server port (assumed to be 587 if not specified) +.TP +.B -x +Account password. You will be prompted for the password interactively if this option is not given. .SH OTHER OPTIONS .TP .B -f -- cgit v1.2.3 From 6f02c6b995795ac788ced8fad5e83bff17444481 Mon Sep 17 00:00:00 2001 From: Marc <40807627+marcwallach@users.noreply.github.com> Date: Tue, 13 Oct 2020 17:32:12 -0300 Subject: Fix typo --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index eeebe53..cf5011a 100755 --- a/bin/mw +++ b/bin/mw @@ -347,7 +347,7 @@ Options allowed with -a: NOTE: Once at least one account is added, you can run \`mbsync -a\` to begin downloading mail. -To chane an account's password, run \`pass edit ${pass_prefix}your@email.com\`. +To change an account's password, run \`pass edit ${pass_prefix}your@email.com\`. EOF exit 1 ;; -- cgit v1.2.3 From a978f36ec2a4309ed545009552797ef52e14b2d6 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 20 Oct 2020 19:05:06 -0400 Subject: protonmail fingerprint fix --- bin/mw | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index cf5011a..59ef132 100755 --- a/bin/mw +++ b/bin/mw @@ -48,7 +48,7 @@ port ${sport:-587} from $fulladdr user $login passwordeval \"pass $pass_prefix$fulladdr\" -$starttlsoff +$tlsline " mbsync_profile="IMAPStore $fulladdr-remote Host $imap @@ -170,7 +170,7 @@ askinfo() { \ read -r imap [ -z "$smtp" ] && echo "Give your email server's SMTP address (excluding the port number):" && read -r smtp - [ "$sport" = 465 ] && starttlsoff="tls_starttls off" + [ "$sport" = 465 ] && tlsline="tls_starttls off" [ -z "$realname" ] && echo "Give the name you would like to be identified by on the email account:" && read -r realname login="${login:-$fulladdr}" @@ -210,10 +210,6 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_ notmuchauto # Create a notmuch config file if not present already. } -protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" - fingerprint="$(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | grep SHA256: | sed 's/^.*: //')" - sed -ibu "s/account $fulladdr/&\ntls_trust_file\ntls_fingerprint $fingerprint/" "$msmtprc" ; rm -f "$msmtprc"bu ;} - getpass() { while : ; do pass rm -f "$pass_prefix$fulladdr" >/dev/null 2>&1 pass insert "$pass_prefix$fulladdr" && break; done ;} @@ -318,7 +314,7 @@ while getopts "fplhdYD:y:i:I:s:S:u:a:n:x:" o; do case "${o}" in smtp="127.0.0.1" sport="1025" ssltype="None" - protonfinger + tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | awk '/SHA256:/ {print $2}')" setact add || exit 1 ;; *) cat << EOF -- cgit v1.2.3 From 96c2492e6de2b7052f049e7645d182b883a107f3 Mon Sep 17 00:00:00 2001 From: inktrap Date: Tue, 27 Oct 2020 23:49:46 +0100 Subject: extend list to also work for symlinked accounts --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index cf5011a..3e83ab2 100755 --- a/bin/mw +++ b/bin/mw @@ -30,7 +30,7 @@ do [ -f "$x" ] && sslcert="$x" && break done || { echo "CA Certificate not found. Please install one or link it to /etc/ssl/certs/ca-certificates.crt" && exit 1 ;} -getaccounts() { accounts="$(find "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} +getaccounts() { accounts="$(find "$accdir" -type f -or -type l | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" ;} -- cgit v1.2.3 From 16a5a450a4e9d65bbf6823a95ac37de9d2ed2aec Mon Sep 17 00:00:00 2001 From: inktrap Date: Wed, 28 Oct 2020 01:04:14 +0100 Subject: use -L --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 3e83ab2..b00f597 100755 --- a/bin/mw +++ b/bin/mw @@ -30,7 +30,7 @@ do [ -f "$x" ] && sslcert="$x" && break done || { echo "CA Certificate not found. Please install one or link it to /etc/ssl/certs/ca-certificates.crt" && exit 1 ;} -getaccounts() { accounts="$(find "$accdir" -type f -or -type l | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} +getaccounts() { accounts="$(find -L "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" ;} -- cgit v1.2.3 From 12664a3f596b347b98ad33e5ff911f8396d5dedc Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 28 Oct 2020 10:24:14 -0400 Subject: error code on failure --- bin/mw | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 59ef132..e02d3ab 100755 --- a/bin/mw +++ b/bin/mw @@ -330,12 +330,13 @@ Main actions: -Y Sync mail for all accounts Options allowed with -a: - -u Account login name if not full address. - -n "Real name" to be on the email account. + -u Account login name if not full address + -n "Real name" to be on the email account -i IMAP server address -I IMAP server port -s SMTP server address -S SMTP server port + -x Password for account (recommended to be in double quotes) -p Install for a Protonmail account. -o Configure address, but keep mail online. -b Assume typical English mailboxes without attempting log-on. @@ -353,7 +354,7 @@ esac done case "$action" in list) list ;; - add) askinfo && getprofiles && writeinfo && getboxes && finalize || delete ;; + add) askinfo && getprofiles && writeinfo && getboxes && finalize || { delete ; exit 1 ;} ;; delete) delete $fulladdr ;; sync) syncwrapper $fulladdr ;; esac -- cgit v1.2.3 From a22d223d7988538560b1227747699d16ff7114b2 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 28 Oct 2020 10:38:04 -0400 Subject: fix #557 --- bin/mw | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index e02d3ab..11d59e9 100755 --- a/bin/mw +++ b/bin/mw @@ -13,7 +13,6 @@ pass_prefix="mw-" muttdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" # Main mutt config location accdir="$muttdir/accounts" # Directory for account settings maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" # Location of mail storage -namere="^[a-z_][a-z0-9_-]*$" # Regex to ensure viable username emailre=".+@.+\..+" # Regex to confirm valid email address muttshare="$prefix/share/mutt-wizard" mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" @@ -228,7 +227,7 @@ Trash Sent Archive" && return 0 if mailboxes="$(mbsync -l "$fulladdr" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then - [ "$accounttype" = "online" ] && sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu + [ -n "${online+x}" ] && sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu return 0 else echo "$mailboxes" @@ -290,7 +289,7 @@ setact() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then trap 'echo -e "\033[0m\n"; exit' INT ABRT -while getopts "fplhdYD:y:i:I:s:S:u:a:n:x:" o; do case "${o}" in +while getopts "fplhodYD:y:i:I:s:S:u:a:n:x:m:" o; do case "${o}" in l) setact list || exit 1 ;; d) setact delete || exit 1 ;; D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; @@ -308,7 +307,6 @@ while getopts "fplhdYD:y:i:I:s:S:u:a:n:x:" o; do case "${o}" in f) setact add || exit 1 ; force=True ;; x) setact add || exit 1 ; password="$OPTARG" ;; p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." - proton=True imap="127.0.0.1" iport="1143" smtp="127.0.0.1" -- cgit v1.2.3 From 50c197ac632a35f3d8d012596f872a7854475030 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 19 Nov 2020 09:20:37 -0500 Subject: attachment fix; documentation fixes --- README.md | 6 ++++-- bin/mw | 2 +- bin/openfile | 13 +++++++------ share/mutt-wizard.muttrc | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'bin/mw') diff --git a/README.md b/README.md index 1027555..31118f1 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ The mutt-wizard is run with the command `mw`. Once everything is setup, you'll u #### Providing arguments -- `-u` -- Give an account username if different from the email address. If you use my [emailwiz](https://github.com/lukesmithxyz/emailwiz), give your username with this option. Not necessary for other accounts. +- `-u` -- Give an account username if different from the email address. - `-n` -- A real name to be used by the account. Put in quotations if multiple words - `-i` -- IMAP server address - `-I` -- IMAP server port (otherwise assumed to be 993) @@ -65,10 +65,10 @@ There's a chance of errors if you use a slow-release distro like Ubuntu, Debian ### Optional +- `pam-gnupg` - Automatically logs you into your GPG key on login so you will never need to input your password once logged on to your system. Check the repo and directions out [here](https://github.com/cruegge/pam-gnupg). - `lynx` - view HTML email in neomutt. - `notmuch` - index and search mail. Install it and run `notmuch setup`, tell it that your mail is in `~/.local/share/mail/` (although `mw` will do this automatically if you haven't set notmuch up before). You can run it in mutt with `ctrl-f`. Run `notmuch new` to process new mail. - `abook` - a terminal-based address book. Pressing tab while typing an address to send mail to will suggest contacts that are in your abook. -- `pam-gnupg` - this is a more general program that I use. It automatically logs you into your GPG key on login so you will never need to input your password once logged on to your system. Check the repo and directions out [here](https://github.com/cruegge/pam-gnupg). - `urlview` - outputs urls in mail to browser. ## Neomutt user interface @@ -88,8 +88,10 @@ To give you an example of the interface, here's an idea: - `?` - see all keyboard shortcuts - `ctrl-j`/`ctrl-k` - move up and down in sidebar, `ctrl-o` opens mailbox. - `ctrl-b` - open a menu to select a url you want to open in you browser. +- ## New stuff and improvements since the original release +- `mw` is now scriptable with command-line options and can run successfully without any interaction, making it possible to deploy in a script. - `isync`/`mbsync` has replaced `offlineimap` as the backend. Offlineimap was error-prone, bloated, used obsolete Python 2 modules and required separate steps to install the system. - `mw` is now an installed program instead of just a script needed to be kept in your mutt folder. - `dialog` is no longer used (le bloat) and the interface is simply text commands. diff --git a/bin/mw b/bin/mw index af4d785..9385bf5 100755 --- a/bin/mw +++ b/bin/mw @@ -337,7 +337,7 @@ Options allowed with -a: -x Password for account (recommended to be in double quotes) -p Install for a Protonmail account. -o Configure address, but keep mail online. - -b Assume typical English mailboxes without attempting log-on. + -f Assume typical English mailboxes without attempting log-on. NOTE: Once at least one account is added, you can run \`mbsync -a\` to begin downloading mail. diff --git a/bin/openfile b/bin/openfile index f6668dc..cf3c6c3 100755 --- a/bin/openfile +++ b/bin/openfile @@ -1,9 +1,10 @@ #!/bin/sh # Helps open a file with xdg-open from mutt in a external program without weird side effects. -[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid xdg-open" -mkdir -p "/tmp/$USER-mutt-tmp" -file="/tmp/$USER-mutt-tmp/$(basename "$1")" -rm -f "$file" -cp "$1" "$file" -$opener "$file" >/dev/null 2>&1 & +tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard/files" +file="$tempdir/$(basename "$1")" +[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open" +mkdir -p "$tempdir" +cp -f "$1" "$file" +$opener "$file" >/dev/null 2>&1 +find "${tempdir:?}" -mtime +1 -type f -delete diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc index 94401e8..f40063d 100644 --- a/share/mutt-wizard.muttrc +++ b/share/mutt-wizard.muttrc @@ -4,6 +4,7 @@ # In the interest of seamless updating, do not edit this file. # If you want to override any settings, set those in your muttrc. set mailcap_path = /usr/local/share/mutt-wizard/mailcap +set mime_type_query_command = "file --mime-type -b %s" set date_format="%y/%m/%d %I:%M%p" set index_format="%2C %Z %?X?A& ? %D %-15.15F %s (%-4.4c)" set sort = 'reverse-date' -- cgit v1.2.3 From 6abcf7073e93b0c40373bef060f51ee006a8a00e Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 26 Nov 2020 20:37:27 -0500 Subject: check for inbox match last in case a subdirectory under the inbox is used for something else closes #581 --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 9385bf5..c622398 100755 --- a/bin/mw +++ b/bin/mw @@ -240,13 +240,13 @@ finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' )" for x in $mailboxes; do case $x in - *[Ii][Nn][Bb][Oo][Xx]*) formatShortcut i inbox "$x"; setBox spoolfile "$x" ;; *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; *[Dd][Rr][Aa][Ff][Tt][Ss]*) setBox postponed "$x"; formatShortcut d drafts "$x" ;; *[Tt][Rr][Aa][Ss][Hh]*) formatShortcut t trash "$x"; setBox trash "$x" ;; *[Jj][Uu][Nn][Kk]*) formatShortcut j junk "$x" ;; *[Aa][Rr][Cc][Hh][Ii][Vv][Ee]*) formatShortcut a archive "$x" ;; *[Ss][Pp][Aa][Mm]*) formatShortcut S spam "$x" ;; + *[Ii][Nn][Bb][Oo][Xx]*) formatShortcut i inbox "$x"; setBox spoolfile "$x" ;; esac done echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" -- cgit v1.2.3 From 6c358df400f3dad2b1573954a1ee181b84836c9b Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 4 Dec 2020 05:53:05 -0500 Subject: fix #588 --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index c622398..8f24118 100755 --- a/bin/mw +++ b/bin/mw @@ -5,7 +5,7 @@ command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && "$GPG" --list-secret-keys $(cat "$PASSWORD_STORE_DIR/.gpg-id") >/dev/null 2>&1 || { printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init \`.\\nIf you don't have a GPG public private key pair, run \`%s --full-gen-key\` first.\\n" "$GPG" - exit + exit 1 } prefix="/usr/local" @@ -348,7 +348,7 @@ exit 1 ;; esac done -! command -v mbsync >/dev/null && [ -z "${force+x}" ] && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit +! command -v mbsync >/dev/null && [ -z "${force+x}" ] && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit 1 case "$action" in list) list ;; -- cgit v1.2.3 From 456d02d1ee0ab196ac256b91c9ac86a01f3c0bb6 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 10 Dec 2020 06:14:50 -0500 Subject: fix #595 --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 8f24118..d179368 100755 --- a/bin/mw +++ b/bin/mw @@ -239,7 +239,7 @@ finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur sed -ibu "/$MARKER/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu" toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' )" for x in $mailboxes; do - case $x in + case "$x" in *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; *[Dd][Rr][Aa][Ff][Tt][Ss]*) setBox postponed "$x"; formatShortcut d drafts "$x" ;; *[Tt][Rr][Aa][Ss][Hh]*) formatShortcut t trash "$x"; setBox trash "$x" ;; -- cgit v1.2.3 From 3d7546974adfa89a1526ac507622a0f8689b6fbf Mon Sep 17 00:00:00 2001 From: Ethan Rietz Date: Tue, 15 Dec 2020 21:45:53 -0500 Subject: Fix mailboxes on macos The Mac version of paste requires "-" to read from STDIN. Without "-", the "mailboxes" line in ~/.config/accounts/.muttrc is empty upon adding a new mailbox via `mw -a `. The Linux version of paste works fine if "-" is added. --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index d179368..a19d1e4 100755 --- a/bin/mw +++ b/bin/mw @@ -237,7 +237,7 @@ Archive" && return 0 finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" sed -ibu "/$MARKER/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu" - toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' )" + toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" for x in $mailboxes; do case "$x" in *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; -- cgit v1.2.3 From 30c4647c98e2e04b86ef6189bf7974b1a3bc20bd Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 24 Dec 2020 20:40:17 -0500 Subject: don't readd same account. fix #558 --- bin/mw | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index d179368..61e7592 100755 --- a/bin/mw +++ b/bin/mw @@ -164,6 +164,8 @@ askinfo() { \ echo "\`$fulladdr\` is not a valid email address. Please retype the address:" read -r fulladdr done + grep -q "Channel\s*$fulladdr$" "$mbsyncrc" && + { echo "$fulladdr has already been added" && exit 1 ;} { [ -z "$imap" ] || [ -z "$smtp" ] ;} && parsedomains [ -z "$imap" ] && echo "Give your email server's IMAP address (excluding the port number):" && read -r imap -- cgit v1.2.3 From a434ac50feb1f6e3142a18d5db0c22c8012cd05a Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 24 Dec 2020 20:43:27 -0500 Subject: fix #596 --- bin/mw | 1 + 1 file changed, 1 insertion(+) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 5a923c8..a207d4e 100755 --- a/bin/mw +++ b/bin/mw @@ -95,6 +95,7 @@ bind index,pager C noop bind index gg first-entry macro index o \"mw -y $fulladdr\" \"run mbsync to sync $fulladdr\" unmailboxes * +unalternates * " else mutt_profile="# vim: filetype=neomuttrc -- cgit v1.2.3 From f589cd4dfdd00f8521c09548b77cba6f995f89a5 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 31 Dec 2020 12:28:15 -0500 Subject: workable mailsync readded to enable autosync the new script manually searches for environmental variables so that it can work from a cronjob and additionally searches for all Xorg displays on Linux so that the display notification should appear correctly no doubt there will be more bugs, but this is what the people want and it's worth working out --- README.md | 107 +++++++++++++++++++++++++++++++++++++++++++++-------------- bin/mailsync | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/mw | 46 +++++++++++++++---------- mw.1 | 13 ++++++++ 4 files changed, 221 insertions(+), 43 deletions(-) create mode 100755 bin/mailsync (limited to 'bin/mw') diff --git a/README.md b/README.md index 31118f1..fc6999a 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,24 @@ Get this great stuff without effort: - A full-featured and autoconfigured email client on the terminal with neomutt -- Mail stored offline so you can view and write email while you're away from internet and keep backups +- Mail stored offline so you can view and write email while you're away from + internet and keep backups +- Provides a `mailsync` script that can be scheduled to run as often as you + like, which downloads/syncs mail and notifies you when new mail has arrived. Specifically, this wizard: - Determines your email server's IMAP and SMTP servers and ports -- Creates dotfiles for `neomutt`, `isync`, and `msmtp` appropriate for your email address -- Encrypts and locally stores your password for easy remote access, accessible only by your GPG key +- Creates dotfiles for `neomutt`, `isync`, and `msmtp` appropriate for your + email address +- Encrypts and locally stores your password for easy remote access, accessible + only by your GPG key - Handles as many as nine separate email accounts automatically - Auto-creates bindings to switch between accounts or between mailboxes -- Provides sensible defaults and an attractive appearance for the neomutt email client -- If mutt-wizard doesn't know your server's IMAP/SMTP info by default, it will prompt you for them and will put them in all the right places. +- Provides sensible defaults and an attractive appearance for the neomutt email + client +- If mutt-wizard doesn't know your server's IMAP/SMTP info by default, it will + prompt you for them and will put them in all the right places. ## Install and Use @@ -33,6 +40,8 @@ The mutt-wizard is run with the command `mw`. Once everything is setup, you'll u - `mw -Y` -- sync all configured email accounts - `mw -d` -- choose an account to delete - `mw -D your@email.com` -- delete account settings without confirmation +- `mw -t 30` -- toggle automatic mailsync to every 30 minutes +- `mw -T` -- toggle mailsync without specifying minutes (default is 10) - `pass edit mw-your@email.com` -- revise an account's password ### Options usable when adding an account @@ -70,6 +79,7 @@ There's a chance of errors if you use a slow-release distro like Ubuntu, Debian - `notmuch` - index and search mail. Install it and run `notmuch setup`, tell it that your mail is in `~/.local/share/mail/` (although `mw` will do this automatically if you haven't set notmuch up before). You can run it in mutt with `ctrl-f`. Run `notmuch new` to process new mail. - `abook` - a terminal-based address book. Pressing tab while typing an address to send mail to will suggest contacts that are in your abook. - `urlview` - outputs urls in mail to browser. +- `cronie` - (or any other major cronjob manager) to set up automatic mail syncing. ## Neomutt user interface @@ -91,43 +101,90 @@ To give you an example of the interface, here's an idea: - ## New stuff and improvements since the original release -- `mw` is now scriptable with command-line options and can run successfully without any interaction, making it possible to deploy in a script. -- `isync`/`mbsync` has replaced `offlineimap` as the backend. Offlineimap was error-prone, bloated, used obsolete Python 2 modules and required separate steps to install the system. -- `mw` is now an installed program instead of just a script needed to be kept in your mutt folder. -- `dialog` is no longer used (le bloat) and the interface is simply text commands. -- More autogenerated shortcuts that allow quickly moving and copying mail between boxes. -- More elegant attachment handling. Image/video/pdf attachments without relying on the neomutt instance. +- `mw` is now scriptable with command-line options and can run successfully + without any interaction, making it possible to deploy in a script. +- `isync`/`mbsync` has replaced `offlineimap` as the backend. Offlineimap was + error-prone, bloated, used obsolete Python 2 modules and required separate + steps to install the system. +- `mw` is now an installed program instead of just a script needed to be kept + in your mutt folder. +- `dialog` is no longer used (le bloat) and the interface is simply text + commands. +- More autogenerated shortcuts that allow quickly moving and copying mail + between boxes. +- More elegant attachment handling. Image/video/pdf attachments without relying + on the neomutt instance. - abook integration by default. -- The messy template files and other directories have been moved or removed, leaving a clean config folder. -- msmtp configs moved to `~/.config/` and mail default location moved to `~/.local/share/mail/`, reducing mess in `~`. +- The messy template files and other directories have been moved or removed, + leaving a clean config folder. +- msmtp configs moved to `~/.config/` and mail default location moved to + `~/.local/share/mail/`, reducing mess in `~`. - `pass` is used as a password manager instead of separately saving passwords. - Script is POSIX sh compliant. -- Error handling for the many people who don't read or follow directions. Less errors generally. +- Error handling for the many people who don't read or follow directions. Less + errors generally. - Addition of a manual `man mw` ## Help the Project! -- Try mutt-wizard out on weird machines and weird email addresses and report any errors. -- Open a PR to add new server information into `domains.csv` so their users can more easily use mutt-wizard. +- Try mutt-wizard out on weird machines and weird email addresses and report + any errors. +- Open a PR to add new server information into `domains.csv` so their users can + more easily use mutt-wizard. - If nothing else, [Donate!](https://paypal.me/LukeMSmith) -See Luke's website [here](https://lukesmith.xyz). Email him at [luke@lukesmith.xyz](mailto:luke@lukesmith.xyz). +See Luke's website [here](https://lukesmith.xyz). Email him at +[luke@lukesmith.xyz](mailto:luke@lukesmith.xyz). mutt-wizard is free/libre software, licensed under the GPLv3. ## Details for Tinkerers - The critical `mutt`/`neomutt` files are in `~/.config/mutt/`. -- Put whatever global settings you want in `muttrc`. mutt-wizard will add some lines to this file which you shouldn't remove unless you know what you're doing, but you can move them up/down over your personal config lines if you need to. If you get binding conflict errors in mutt, you might need to do this. -- Each of the accounts that mutt-wizard generates will have custom settings set in a separate file in `accounts/`. You can edit these freely if you want to tinker with settings specific to an account. -- In `/usr/share/mutt-wizard` are several global config files, including `mutt-wizard`'s default settings. You can overwride this in your `muttrc` if you wish. +- Put whatever global settings you want in `muttrc`. mutt-wizard will add some + lines to this file which you shouldn't remove unless you know what you're + doing, but you can move them up/down over your personal config lines if you + need to. If you get binding conflict errors in mutt, you might need to do + this. +- Each of the accounts that mutt-wizard generates will have custom settings set + in a separate file in `accounts/`. You can edit these freely if you want to + tinker with settings specific to an account. +- In `/usr/share/mutt-wizard` are several global config files, including + `mutt-wizard`'s default settings. You can overwride this in your `muttrc` if + you wish. ## Watch out for these things: -- Gmail accounts can now create 'App Password' to use with """less secure""" applications. This password is single use (ie. for setup) and will be stored and encrypted locally. Enabling third-party applications requires turning off two-factor authentication and this will circumvent that. You might also need to manually "Enable IMAP" in the settings. -- Protonmail accounts will require you to set up "Protonmail Bridge" to access PM's IMAP and SMTP servers. Configure that before running mutt-wizard. Note that when mutt-wizard asks for a password, you should put in your [bridge password](https://protonmail.com/bridge/thunderbird#3), not your account password. -- Protonmail bridge is prone to timing out. Watch out for this while adding an account. If the bridge times out, try again. It might help to [increase the timeout](https://protonmail.com/support/knowledge-base/thunderbird-connection-server-timed-error/) in your `mbsyncrc`. -- If you have a university email, or enterprise-hosted email for work, there might be other hurdles or two-factor authentication you have to jump through. Some, for example, will want you to create a separate IMAP password, etc. - - `isync` is not fully UTF-8 compatible, so non-Latin characters may be garbled (although sync should succeed). `mw` will also not autocreate mailbox shortcuts since it is looking for English mailbox names. I strongly recommend you to set your email language to English on your mail server to avoid these problems. + +### Gmail + +Gmail accounts should require an +[application password](https://support.google.com/accounts/answer/185833) to +work unless you allow Gmail to access "less secure" applications. You may also +need to "Enable IMAP" in your Gmail settings. + +### Protonmail + +Protonmail accounts will require you to set up "Protonmail Bridge" to access +PM's IMAP and SMTP servers. Configure that before running mutt-wizard. Note +that when mutt-wizard asks for a password, you should put in your +[bridge password](https://protonmail.com/bridge/thunderbird#3), not your +account password. + +Protonmail bridge is prone to timing out. Watch out for this while adding an +account. If the bridge times out, try again. It might help to +[increase the timeout](https://protonmail.com/support/knowledge-base/thunderbird-connection-server-timed-error/) +in your `mbsyncrc`. + +### Other + +- If you have a university email, or enterprise-hosted email for work, there + might be other hurdles or two-factor authentication you have to jump through. + Some, for example, will want you to create a separate IMAP password, etc. + - `isync` is not fully UTF-8 compatible, so non-Latin characters may be + garbled (although sync should succeed). `mw` will also not autocreate + mailbox shortcuts since it is looking for English mailbox names. I strongly + recommend you to set your email language to English on your mail server to + avoid these problems. ## To-do diff --git a/bin/mailsync b/bin/mailsync new file mode 100755 index 0000000..02e4f98 --- /dev/null +++ b/bin/mailsync @@ -0,0 +1,98 @@ +#!/bin/sh + +# - Syncs mail for all accounts, or a single account given as an argument. +# - Displays a notification showing the number of new mails. +# - Displays a notification for each new mail with its subject displayed. +# - Runs notmuch to index new mail. +# - This script can be set up as a cron job for automated mail syncing. + +# There are many arbitrary and ugly features in this script because it is +# inherently difficult to pass environmental variables to cronjobs and other +# issues. It also should at least be compatible with Linux (and maybe BSD) with +# Xorg and MacOS as well. + +# Run only if user logged in (prevent cron errors) +pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;} +# Run only if not already running in other instance +pgrep -x mbsync >/dev/null && { echo "mbsync is already running." ; exit ;} + +# First, we have to get the right variables for the mbsync file, the pass +# archive, notmuch and the GPG home. This is done by searching common profile +# files for variable assignments. This is ugly, but there are few options that +# will work on the maximum number of machines. +eval `grep -h -- \ + "^\(export \)\?\(MBSYNCRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\)=" \ + "$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.pam_environment" 2>/dev/null` +# One alternative to this kind of command would be marking the script for +# /bin/sh -l. That might cause other problems on other particular setups that +# do more complicated things on login, or those people who assign environmental +# variables in shell rc files. + +# This variable might be required for soysdemd users, but it will break the +# script on Artix runit. +# export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus +export GPG_TTY=$TTY + +[ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" + +# Settings are different for MacOS (Darwin) systems. +case "$(uname)" in + Darwin) + notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} + messageinfo() { osascript -e "display notification with title \"📧 $from\" subtitle \"$subject\"" ;} + ;; + *) + displays="$(ps axo user,cmd | grep "^$USER\s\+.*Xorg" | grep -wo "[0-9]*:[0-9]\+")" + notify() { for x in $displays; do + export DISPLAY=$x + notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account." + done ;} + messageinfo() { for x in $displays; do + export DISPLAY=$x + notify-send --app-name="mutt-wizard" "📧$from:" "$subject" + done ;} + ;; +esac + +# Check account for new mail. Notify if there is new content. +syncandnotify() { + acc="$(echo "$account" | sed "s/.*\///")" + if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi + new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$HOME/.config/mutt/.mailsynclastrun" 2> /dev/null) + newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) + if [ "$newcount" -gt "0" ]; then + notify "$acc" "$newcount" & + for file in $new; do + # Extract subject and sender from mail. + from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//') + subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n') + messageinfo & + done + fi +} + +# Sync accounts passed as argument or all. +if [ "$#" -eq "0" ]; then + accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" +else + for arg in "$@"; do + [ "${arg%${arg#?}}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1 + done + accounts=$* +fi + +#( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null + +# Parallelize multiple accounts +for account in $accounts +do + syncandnotify & +done + +wait +#( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null + +notmuch new 2>/dev/null + +#Create a touch file that indicates the time of the last run of mailsync +touch "$HOME/.config/mutt/.mailsynclastrun" diff --git a/bin/mw b/bin/mw index a207d4e..f713761 100755 --- a/bin/mw +++ b/bin/mw @@ -21,7 +21,7 @@ cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard" muttrc="$muttdir/muttrc" msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" msmtplog="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/msmtp.log" -MARKER="# mw-autogenerated" +marker="# mw-autogenerated" alias mbsync='mbsync -c "$mbsyncrc"' for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/" @@ -151,7 +151,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then [ -z "$fulladdr" ] && echo "Invalid account name given." && return 1 - sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -rf "$mbsyncrc"bu + sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc" sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu @@ -205,9 +205,9 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_ # Create a muttrc for viewing mail. echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc" [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" - ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig $MARKER" >> "$muttrc" - ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc $MARKER" >> "$muttrc" - echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\" $MARKER" >> "$muttrc" + ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig $marker" >> "$muttrc" + ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc $marker" >> "$muttrc" + echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\" $marker" >> "$muttrc" notmuchauto # Create a notmuch config file if not present already. } @@ -216,12 +216,12 @@ getpass() { while : ; do pass rm -f "$pass_prefix$fulladdr" >/dev/null 2>&1 pass insert "$pass_prefix$fulladdr" && break; done ;} formatShortcut() { toappend="$toappend -macro index,pager g$1 \"=$3\" \"go to $2\" $MARKER -macro index,pager M$1 \";=$3\" \"move mail to $2\" $MARKER -macro index,pager C$1 \";=$3\" \"copy mail to $2\" $MARKER" >> "$accdir/$idnum-$fulladdr.muttrc" ;} +macro index,pager g$1 \"=$3\" \"go to $2\" $marker +macro index,pager M$1 \";=$3\" \"move mail to $2\" $marker +macro index,pager C$1 \";=$3\" \"copy mail to $2\" $marker" >> "$accdir/$idnum-$fulladdr.muttrc" ;} setBox() { toappend="$toappend -set $1 = \"+$2\" $MARKER" ;} +set $1 = \"+$2\" $marker" ;} getboxes() { [ -n "${force+x}" ] && mailboxes="INBOX Drafts @@ -239,7 +239,7 @@ Archive" && return 0 fi ;} finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" - sed -ibu "/$MARKER/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu" + sed -ibu "/$marker/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu" toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" for x in $mailboxes; do case "$x" in @@ -257,12 +257,6 @@ finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" return 0 ;} -syncwrapper() { mbsync "${1:--a}" & - ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null - wait - ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null - notmuch new ;} - notmuchauto() { \ [ -z "$NOTMUCH_CONFIG" ] && NOTMUCH_CONFIG="$HOME/.notmuch-config" [ -f "$NOTMUCH_CONFIG" ] && return 0 @@ -282,6 +276,17 @@ synchronize_flags=true gpg_path=$GPG" echo "$nmbasic" > "$NOTMUCH_CONFIG" ;} +togglecron() { cron="$(mktemp)" + crontab -l > "$cron" + if grep -q mailsync "$cron"; then + echo "Removing automatic mailsync..." + sed -ibu /mailsync/d "$cron"; rm -f "$cron"bu + else + echo "Adding automatic mailsync every ${cronmin:-10} minutes..." + echo "*/${cronmin-10} * * * * /usr/local/bin/mailsync" >> "$cron" + fi && + crontab "$cron"; rm -f "$cron" ;} + setact() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then echo "Running $1 with $action..." echo "Incompatible options given. Only one action may be specified per run." @@ -292,7 +297,7 @@ setact() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then trap 'echo -e "\033[0m\n"; exit' INT ABRT -while getopts "fplhodYD:y:i:I:s:S:u:a:n:x:m:" o; do case "${o}" in +while getopts "fplhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in l) setact list || exit 1 ;; d) setact delete || exit 1 ;; D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; @@ -309,6 +314,8 @@ while getopts "fplhodYD:y:i:I:s:S:u:a:n:x:m:" o; do case "${o}" in o) setact add || exit 1 ; online=True ;; f) setact add || exit 1 ; force=True ;; x) setact add || exit 1 ; password="$OPTARG" ;; + t) setact toggle || exit 1 ; cronmin="$OPTARG" ;; + T) setact toggle || exit 1 ;; p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." imap="127.0.0.1" iport="1143" @@ -329,6 +336,8 @@ Main actions: -D your@email.com Force remove account without confirmation -y your@email.com Sync mail for account by name -Y Sync mail for all accounts + -t number Toggle automatic mailsync every minutes + -T Toggle automatic mailsync Options allowed with -a: -u Account login name if not full address @@ -357,5 +366,6 @@ case "$action" in list) list ;; add) askinfo && getprofiles && writeinfo && getboxes && finalize || { delete ; exit 1 ;} ;; delete) delete $fulladdr ;; - sync) syncwrapper $fulladdr ;; + sync) mailsync $fulladdr ;; + toggle) togglecron ;; esac diff --git a/mw.1 b/mw.1 index 3ed4d95..920e513 100644 --- a/mw.1 +++ b/mw.1 @@ -35,6 +35,12 @@ download and upload mail for an email account .TP .B -Y sync all email accounts +.TP +.B -t 15 +toggle a cronjob that syncs your mail every 15 minutes (or any other number under 60) +.TP +.B -T +toggle a cronjob without specifying minutes between sync .SH OPTIONS FOR ADDING ACCOUNTS These can be specified on the command line, otherwise, you will be prompted for what is necessary. mutt-wizard knows the IMAP/SMTP server information for most email providers, so specifying them is usually redundant. .TP @@ -75,6 +81,13 @@ connection will still be attempted in setup to discover mailboxes. Add a Protonmail account. Protonmail Bridge must be installed and set up. .SH DETAILS .TP +.B mailsync +mutt-wizard calls a script +.I mailsync +to sync mail. This script additionally indexes new mail with notmuch and gives you a notification if new mail has arrived. If you want to bypass its additional features, you can always just run +.I mbsync -a +to sync your mail directly. +.TP .B Mail location If the user chooses to keep offline email with .B isync, -- cgit v1.2.3 From 63466ad954d5763faa18039fe42ace56af03ce4c Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 2 Jan 2021 10:18:41 -0500 Subject: imap ssl off when unencrypted port given --- bin/mw | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index f713761..f54934c 100755 --- a/bin/mw +++ b/bin/mw @@ -35,6 +35,7 @@ list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" ;} getprofiles() { \ unset msmtp_header msmtp_profile mutt_profile mbsync_profile + [ "$iport" = "1143" ] && imapssl="None" msmtp_header="defaults auth on tls on @@ -55,7 +56,7 @@ Port ${iport:-993} User $login PassCmd \"pass $pass_prefix$fulladdr\" AuthMechs LOGIN -SSLType ${ssltype:-IMAPS} +SSLType ${imapssl:-IMAPS} CertificateFile $sslcert MaildirStore $fulladdr-local @@ -283,7 +284,7 @@ togglecron() { cron="$(mktemp)" sed -ibu /mailsync/d "$cron"; rm -f "$cron"bu else echo "Adding automatic mailsync every ${cronmin:-10} minutes..." - echo "*/${cronmin-10} * * * * /usr/local/bin/mailsync" >> "$cron" + echo "*/${cronmin-10} * * * * $prefix/bin/mailsync" >> "$cron" fi && crontab "$cron"; rm -f "$cron" ;} @@ -321,7 +322,6 @@ while getopts "fplhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in iport="1143" smtp="127.0.0.1" sport="1025" - ssltype="None" tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | awk '/SHA256:/ {print $2}')" setact add || exit 1 ;; -- cgit v1.2.3 From 4dbf70e40355b73b16a3b0b010960a0d1a681740 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 09:17:59 -0500 Subject: less gimicky feedback --- bin/mw | 12 +++++------- share/domains.csv | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index f54934c..3586df7 100755 --- a/bin/mw +++ b/bin/mw @@ -3,7 +3,7 @@ command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" [ -z ${PASSWORD_STORE_DIR+x} ] && PASSWORD_STORE_DIR="$HOME/.password-store" [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && - "$GPG" --list-secret-keys $(cat "$PASSWORD_STORE_DIR/.gpg-id") >/dev/null 2>&1 || { + "$GPG" --list-secret-keys "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" >/dev/null 2>&1 || { printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init \`.\\nIf you don't have a GPG public private key pair, run \`%s --full-gen-key\` first.\\n" "$GPG" exit 1 } @@ -235,7 +235,7 @@ Archive" && return 0 return 0 else echo "$mailboxes" - printf "\033[31m\033[31mLog-on not successful.\033[0m\\nIt seems that either you inputted the wrong password or server settings, or there are other requirements for your account out of the control of mutt-wizard.\\n" + echo "Log-on not successful." return 1 fi ;} @@ -254,7 +254,7 @@ finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur esac done echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" - [ -z "${online+x}" ] && printf "\033[33mYou should now be able to run \`\033[32mmw -y %s\033[33m\` to begin to download your mail.\033[0m\\n" "$fulladdr" + [ -z "${online+x}" ] && echo "$fulladdr (account #$idnum) added successfully." command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" return 0 ;} @@ -296,8 +296,6 @@ setact() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then action="$1" fi; } -trap 'echo -e "\033[0m\n"; exit' INT ABRT - while getopts "fplhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in l) setact list || exit 1 ;; d) setact delete || exit 1 ;; @@ -360,12 +358,12 @@ exit 1 ;; esac done -! command -v mbsync >/dev/null && [ -z "${force+x}" ] && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit 1 +! command -v mbsync >/dev/null && [ -z "${force+x}" ] && echo "\`mbsync (isync package)\` must be installed." && exit 1 case "$action" in list) list ;; add) askinfo && getprofiles && writeinfo && getboxes && finalize || { delete ; exit 1 ;} ;; - delete) delete $fulladdr ;; + delete) delete ;; sync) mailsync $fulladdr ;; toggle) togglecron ;; esac diff --git a/share/domains.csv b/share/domains.csv index 64dcf80..50ce1ff 100644 --- a/share/domains.csv +++ b/share/domains.csv @@ -1,8 +1,8 @@ +ADDRESS,IMAP,imap port,SMTP,smtp port 126.com,imap.126.com,993,smtp.126.com,587 163.com,imap.163.com,993,smtp.163.com,587 420blaze.it,mail.cock.li,993,mail.cock.li,587 8chan.co,mail.cock.li,993,mail.cock.li,587 -ADDRESS,IMAP,imap port,SMTP,smtp port aaathats3as.com,mail.cock.li,993,mail.cock.li,587 accountant.com,imap.mail.com,993,smtp.mail.com,587 activist.com,imap.mail.com,993,smtp.mail.com,587 -- cgit v1.2.3 From ca9f1a12ccbc01889fd2a1257462594e4d2ea272 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:13:48 -0500 Subject: use curl to login rm mbsync requirement for online storage --- README.md | 5 +++-- bin/mw | 17 ++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'bin/mw') diff --git a/README.md b/README.md index fc6999a..46c4a36 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,10 @@ The mutt-wizard is run with the command `mw`. Once everything is setup, you'll u ## Dependencies - `neomutt` - the email client. -- `isync` - downloads and syncs the mail. (required at install) +- `curl` - tests connections (required at install). +- `isync` - downloads and syncs the mail (required if storing IMAP mail locally). - `msmtp` - sends the email. -- `pass` - safely encrypts passwords (required at install) +- `pass` - safely encrypts passwords (required at install). There's a chance of errors if you use a slow-release distro like Ubuntu, Debian or Mint. If you get errors in `neomutt`, install the most recent version manually or manually remove the offending lines in the config in `/usr/share/mutt-wizard/mutt-wizard.muttrc`. diff --git a/bin/mw b/bin/mw index 3586df7..f009e90 100755 --- a/bin/mw +++ b/bin/mw @@ -199,9 +199,8 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_ # On Ubuntu/Debian, a link is needed since they use an older version. command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null - # Create the mbsync config file. - mkdir -p "${mbsyncrc%/*}" - echo "$mbsync_profile" >> "$mbsyncrc" + # Create the mbsync config file if local account. + [ -z "${online+x}" ] && mkdir -p "${mbsyncrc%/*}" && echo "$mbsync_profile" >> "$mbsyncrc" # Create a muttrc for viewing mail. echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc" @@ -230,14 +229,10 @@ Junk Trash Sent Archive" && return 0 - if mailboxes="$(mbsync -l "$fulladdr" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then - [ -n "${online+x}" ] && sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu - return 0 - else - echo "$mailboxes" - echo "Log-on not successful." - return 1 - fi ;} + info="$(curl -s --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" || + { echo "Log-on not successful." ; exit 1 ;} + mailboxes="$(echo "$info" | sed "s/.*\" //" | tr -d ' ')" +} finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" sed -ibu "/$marker/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu" -- cgit v1.2.3 From 78030885b4e3153b69d408424beeb544adc093a8 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:25:09 -0500 Subject: fix --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index f009e90..e2d8f41 100755 --- a/bin/mw +++ b/bin/mw @@ -229,8 +229,8 @@ Junk Trash Sent Archive" && return 0 - info="$(curl -s --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" || - { echo "Log-on not successful." ; exit 1 ;} + info="$(curl -s --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" + [ -z "$info" ] && echo "Log-on not successful." && return 1 mailboxes="$(echo "$info" | sed "s/.*\" //" | tr -d ' ')" } -- cgit v1.2.3 From f83c45689b21fccb917fdb4c555280eaf19ef78f Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:34:00 -0500 Subject: temporary soydevery --- bin/mw | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index e2d8f41..9950fae 100755 --- a/bin/mw +++ b/bin/mw @@ -157,6 +157,12 @@ delete() { if [ -z "${fulladdr+x}" ]; then sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu pass rm -f "$pass_prefix$fulladdr" >/dev/null 2>&1 + + # Get rid of those multiple newlines because I don't know awk well enough to do it by default lol. + for file in "$msmtprc" "$mbsyncrc"; do + tr '\n' '|' < "$file" | sed "s/||\+/||/g" | tr '|' '\n' >> "$file"bu + mv -f "$file"bu "$file" + done } askinfo() { \ -- cgit v1.2.3 From 16de5dc350d06cd45338271a2286c0629ef20435 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:38:25 -0500 Subject: don't ask realname if not given; assume userid --- README.md | 2 +- bin/mw | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/README.md b/README.md index 46c4a36..a68e298 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ The mutt-wizard is run with the command `mw`. Once everything is setup, you'll u #### Providing arguments - `-u` -- Give an account username if different from the email address. -- `-n` -- A real name to be used by the account. Put in quotations if multiple words +- `-n` -- A real name to be used by the account. Put in quotations if multiple words. - `-i` -- IMAP server address - `-I` -- IMAP server port (otherwise assumed to be 993) - `-s` -- SMTP server address diff --git a/bin/mw b/bin/mw index 9950fae..0c00e53 100755 --- a/bin/mw +++ b/bin/mw @@ -180,8 +180,7 @@ askinfo() { \ [ -z "$smtp" ] && echo "Give your email server's SMTP address (excluding the port number):" && read -r smtp [ "$sport" = 465 ] && tlsline="tls_starttls off" - [ -z "$realname" ] && echo "Give the name you would like to be identified by on the email account:" && - read -r realname + [ -z "$realname" ] && realname="${fulladdr%%@*}" login="${login:-$fulladdr}" if [ -n "${password+x}" ]; then createpass -- cgit v1.2.3 From 564c529f8ec3aa6697d966dde89abdf132012240 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 7 Jan 2021 17:04:08 -0500 Subject: curl redirects and times out --- bin/mailsync | 6 +----- bin/mw | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'bin/mw') diff --git a/bin/mailsync b/bin/mailsync index 1d676b8..3fac7c5 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -81,16 +81,12 @@ else accounts=$* fi -#( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null - # Parallelize multiple accounts -for account in $accounts -do +for account in $accounts; do syncandnotify & done wait -#( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null notmuch new 2>/dev/null diff --git a/bin/mw b/bin/mw index 0c00e53..19befb3 100755 --- a/bin/mw +++ b/bin/mw @@ -234,7 +234,7 @@ Junk Trash Sent Archive" && return 0 - info="$(curl -s --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" + info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" [ -z "$info" ] && echo "Log-on not successful." && return 1 mailboxes="$(echo "$info" | sed "s/.*\" //" | tr -d ' ')" } -- cgit v1.2.3 From 038b90bb46115c5696fdaee6fd05394ca14e7736 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 7 Jan 2021 18:11:35 -0500 Subject: tweaks cloe #367 --- bin/mw | 90 ++++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 46 insertions(+), 44 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 19befb3..a2ad6bd 100755 --- a/bin/mw +++ b/bin/mw @@ -1,13 +1,5 @@ #!/bin/sh -command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" -[ -z ${PASSWORD_STORE_DIR+x} ] && PASSWORD_STORE_DIR="$HOME/.password-store" -[ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && - "$GPG" --list-secret-keys "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" >/dev/null 2>&1 || { - printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init \`.\\nIf you don't have a GPG public private key pair, run \`%s --full-gen-key\` first.\\n" "$GPG" - exit 1 - } - prefix="/usr/local" pass_prefix="mw-" muttdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" # Main mutt config location @@ -24,18 +16,28 @@ msmtplog="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/msmtp.log" marker="# mw-autogenerated" alias mbsync='mbsync -c "$mbsyncrc"' -for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/" -do +for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/"; do [ -f "$x" ] && sslcert="$x" && break done || { echo "CA Certificate not found. Please install one or link it to /etc/ssl/certs/ca-certificates.crt" && exit 1 ;} +checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" + PASSWORD_STORE_DIR="${PASSWORD_STORE_DIR:-$HOME/.password-store}" + [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && + "$GPG" --list-secret-keys "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" >/dev/null 2>&1 || { + echo "First run \`pass init \` to set up a password archive." + echo "(If you don't already have a GPG key pair, first run \`$GPG --fullgenkey\`.)" + exit 1 ;} ;} + getaccounts() { accounts="$(find -L "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" ;} getprofiles() { \ unset msmtp_header msmtp_profile mutt_profile mbsync_profile - [ "$iport" = "1143" ] && imapssl="None" + case "$iport" in + 1143) imapssl=None ;; + 143) imapssl=STARTTLS ;; + esac msmtp_header="defaults auth on tls on @@ -296,34 +298,7 @@ setact() { if [ -n "${action+x}" ] && [ "$action" != "$1" ]; then action="$1" fi; } -while getopts "fplhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in - l) setact list || exit 1 ;; - d) setact delete || exit 1 ;; - D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; - y) setact sync || exit 1 ; fulladdr="$OPTARG" ;; - Y) setact sync || exit 1 ;; - a) setact add || exit 1 ; fulladdr="$OPTARG" ;; - i) setact add || exit 1 ; imap="$OPTARG" ;; - I) setact add || exit 1 ; iport="$OPTARG" ;; - s) setact add || exit 1 ; smtp="$OPTARG" ;; - S) setact add || exit 1 ; sport="$OPTARG" ;; - u) setact add || exit 1 ; login="$OPTARG" ;; - n) setact add || exit 1 ; realname="$OPTARG" ;; - m) setact add || exit 1 ; maxmes="$OPTARG" ;; - o) setact add || exit 1 ; online=True ;; - f) setact add || exit 1 ; force=True ;; - x) setact add || exit 1 ; password="$OPTARG" ;; - t) setact toggle || exit 1 ; cronmin="$OPTARG" ;; - T) setact toggle || exit 1 ;; - p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." - imap="127.0.0.1" - iport="1143" - smtp="127.0.0.1" - sport="1025" - tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | awk '/SHA256:/ {print $2}')" - setact add || exit 1 - ;; - *) cat << EOF +mwinfo() { cat << EOF mw: mutt-wizard, auto-configure email accounts for mutt including downloadable mail with \`isync\`. @@ -354,16 +329,43 @@ NOTE: Once at least one account is added, you can run To change an account's password, run \`pass edit ${pass_prefix}your@email.com\`. EOF -exit 1 -;; -esac done +} -! command -v mbsync >/dev/null && [ -z "${force+x}" ] && echo "\`mbsync (isync package)\` must be installed." && exit 1 +while getopts "fplhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in + l) setact list || exit 1 ;; + d) setact delete || exit 1 ;; + D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; + y) setact sync || exit 1 ; fulladdr="$OPTARG" ;; + Y) setact sync || exit 1 ;; + a) setact add || exit 1 ; fulladdr="$OPTARG" ;; + i) setact add || exit 1 ; imap="$OPTARG" ;; + I) setact add || exit 1 ; iport="$OPTARG" ;; + s) setact add || exit 1 ; smtp="$OPTARG" ;; + S) setact add || exit 1 ; sport="$OPTARG" ;; + u) setact add || exit 1 ; login="$OPTARG" ;; + n) setact add || exit 1 ; realname="$OPTARG" ;; + m) setact add || exit 1 ; maxmes="$OPTARG" ;; + o) setact add || exit 1 ; online=True ;; + f) setact add || exit 1 ; force=True ;; + x) setact add || exit 1 ; password="$OPTARG" ;; + t) setact toggle || exit 1 ; cronmin="$OPTARG" ;; + T) setact toggle || exit 1 ;; + p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." + imap="127.0.0.1" + iport="1143" + smtp="127.0.0.1" + sport="1025" + tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | awk '/SHA256:/ {print $2}')" + setact add || exit 1 + ;; + *) mwinfo; exit 1 ;; +esac done case "$action" in list) list ;; - add) askinfo && getprofiles && writeinfo && getboxes && finalize || { delete ; exit 1 ;} ;; + add) checkbasics && askinfo && getprofiles && writeinfo && getboxes && finalize || { delete ; exit 1 ;} ;; delete) delete ;; sync) mailsync $fulladdr ;; toggle) togglecron ;; + *) mwinfo; exit 1 ;; esac -- cgit v1.2.3 From d7fd47516f9283e70bd4d0e5f19391e161247919 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 8 Jan 2021 08:36:17 -0500 Subject: fix #615 --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index a2ad6bd..493a5f2 100755 --- a/bin/mw +++ b/bin/mw @@ -238,7 +238,7 @@ Sent Archive" && return 0 info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" [ -z "$info" ] && echo "Log-on not successful." && return 1 - mailboxes="$(echo "$info" | sed "s/.*\" //" | tr -d ' ')" + mailboxes="$(echo "$info" | sed "s/.*\" //;s/\"//g" | tr -d ' ')" } finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" -- cgit v1.2.3 From 3c3daa3508bc16ca9db03e7183e8cbefcb00f65f Mon Sep 17 00:00:00 2001 From: ret2hell Date: Sat, 16 Jan 2021 22:18:16 +0000 Subject: changed 'gpg --fullgenkey' to the correct command. --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 493a5f2..4716989 100755 --- a/bin/mw +++ b/bin/mw @@ -25,7 +25,7 @@ checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && "$GPG" --list-secret-keys "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" >/dev/null 2>&1 || { echo "First run \`pass init \` to set up a password archive." - echo "(If you don't already have a GPG key pair, first run \`$GPG --fullgenkey\`.)" + echo "(If you don't already have a GPG key pair, first run \`$GPG --full-gen-key\`.)" exit 1 ;} ;} getaccounts() { accounts="$(find -L "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} -- cgit v1.2.3 From 79bb0437267b55a85bbdcf4f9b635be43091a73f Mon Sep 17 00:00:00 2001 From: Gianni Van Hoecke Date: Fri, 22 Jan 2021 20:26:45 +0100 Subject: :bug: Set protocol to `imap` when using ProtonMail Part 1 of 2 for "Log-on not successful" bug when using ProtonMail. The curl login check defaults to `imaps` when `protocol` isn't set. Because ProtonMail isn't using any TLS, we have to use the `imap` protocol. The `protocol` variable was never set, so now we set it when the ProtonMail flag (-p) is set. Bug mentioned in: Fixes: - https://github.com/LukeSmithxyz/mutt-wizard/issues/608 - https://github.com/LukeSmithxyz/mutt-wizard/issues/622 --- bin/mw | 1 + 1 file changed, 1 insertion(+) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 4716989..30aabab 100755 --- a/bin/mw +++ b/bin/mw @@ -351,6 +351,7 @@ while getopts "fplhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in t) setact toggle || exit 1 ; cronmin="$OPTARG" ;; T) setact toggle || exit 1 ;; p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." + protocol="imap" imap="127.0.0.1" iport="1143" smtp="127.0.0.1" -- cgit v1.2.3 From 5920ca462db40309e927e1d58feb08023968e687 Mon Sep 17 00:00:00 2001 From: Gianni Van Hoecke Date: Fri, 22 Jan 2021 20:33:29 +0100 Subject: :bug: Supply imap port to curl login check Part 2 of 2 for "Log-on not successful" bug when using ProtonMail. The curl login check uses the imap(s) protocol, which means it will use the default ports. However, when using ProtonMail, these ports are different (namely 1143 instead of 993). We now use the port variable in the curl login command, defaulting to 993 when the port was not overridden. The port variable was already set when the ProtonMail flag (-p) was set. Bug mentioned in: Fixes: - https://github.com/LukeSmithxyz/mutt-wizard/issues/608 - https://github.com/LukeSmithxyz/mutt-wizard/issues/622 --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 30aabab..67c389d 100755 --- a/bin/mw +++ b/bin/mw @@ -236,7 +236,7 @@ Junk Trash Sent Archive" && return 0 - info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" + info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && echo "Log-on not successful." && return 1 mailboxes="$(echo "$info" | sed "s/.*\" //;s/\"//g" | tr -d ' ')" } -- cgit v1.2.3 From 3589c36a381a776776191752265f926a03275ff2 Mon Sep 17 00:00:00 2001 From: PRESFIL Date: Sat, 23 Jan 2021 00:29:20 +0300 Subject: Fix: `macro index o` overlapping with next account When the transition is made from an offline profile to an online profile, there is still someone else's macro - side effects... Variables, macros, and so on must be taken-into-account **symmetrically** with any of the `mutt-wizard`'s profiles. --- bin/mw | 1 + 1 file changed, 1 insertion(+) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 67c389d..f6fd6c0 100755 --- a/bin/mw +++ b/bin/mw @@ -122,6 +122,7 @@ bind index,pager g noop bind index,pager M noop bind index,pager C noop bind index gg first-entry +unmacro index o unmailboxes * " fi -- cgit v1.2.3 From 9662299d4e508f4c6706c7c6709730f06e60aa52 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 30 Jan 2021 16:12:11 -0500 Subject: bugfixes and simplification. fixes #517 #546 #600 #632 remove old vars like pass_prefix, muttdir reorder mailbox detection to find inbox case and later delim offline delim set to _ which should avoid most issues --- bin/mw | 91 ++++++++++++++++++++++++++++++------------------------------------ 1 file changed, 41 insertions(+), 50 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index f6fd6c0..cf42822 100755 --- a/bin/mw +++ b/bin/mw @@ -1,19 +1,15 @@ #!/bin/sh prefix="/usr/local" -pass_prefix="mw-" -muttdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" # Main mutt config location -accdir="$muttdir/accounts" # Directory for account settings -maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" # Location of mail storage -emailre=".+@.+\..+" # Regex to confirm valid email address +maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" muttshare="$prefix/share/mutt-wizard" -mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" mwconfig="$muttshare/mutt-wizard.muttrc" cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard" -muttrc="$muttdir/muttrc" +muttrc="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/muttrc" +accdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/accounts" msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" msmtplog="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/msmtp.log" -marker="# mw-autogenerated" +mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" alias mbsync='mbsync -c "$mbsyncrc"' for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/"; do @@ -25,10 +21,10 @@ checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && "$GPG" --list-secret-keys "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" >/dev/null 2>&1 || { echo "First run \`pass init \` to set up a password archive." - echo "(If you don't already have a GPG key pair, first run \`$GPG --full-gen-key\`.)" + echo "(If you don't already have a GPG key pair, first run \`$GPG --full-generate-key\`.)" exit 1 ;} ;} -getaccounts() { accounts="$(find -L "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} +getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" ;} @@ -49,14 +45,14 @@ host $smtp port ${sport:-587} from $fulladdr user $login -passwordeval \"pass $pass_prefix$fulladdr\" +passwordeval \"pass $fulladdr\" $tlsline " mbsync_profile="IMAPStore $fulladdr-remote Host $imap Port ${iport:-993} User $login -PassCmd \"pass $pass_prefix$fulladdr\" +PassCmd \"pass $fulladdr\" AuthMechs LOGIN SSLType ${imapssl:-IMAPS} CertificateFile $sslcert @@ -64,8 +60,8 @@ CertificateFile $sslcert MaildirStore $fulladdr-local Subfolders Verbatim Path ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/ -Inbox ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/INBOX -Flatten . +Inbox ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-INBOX} +Flatten _ Channel $fulladdr Expunge Both @@ -111,7 +107,7 @@ set folder = \"imaps://$login@$imap:${iport:-993}\" set imap_user = \"$login\" set header_cache = $cachedir/$fulladdr/headers set message_cachedir = $cachedir/$fulladdr/bodies -set imap_pass = \"\`pass $pass_prefix$fulladdr\`\" +set imap_pass = \"\`pass $fulladdr\`\" set mbox_type = Maildir set ssl_starttls = yes @@ -159,7 +155,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc" sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu - pass rm -f "$pass_prefix$fulladdr" >/dev/null 2>&1 + pass rm -f "$fulladdr" >/dev/null 2>&1 # Get rid of those multiple newlines because I don't know awk well enough to do it by default lol. for file in "$msmtprc" "$mbsyncrc"; do @@ -171,11 +167,11 @@ delete() { if [ -z "${fulladdr+x}" ]; then askinfo() { \ [ -z "$fulladdr" ] && echo "Give the full email address to add:" && read -r fulladdr - while ! echo "$fulladdr" | grep -qE "$emailre"; do + while ! echo "$fulladdr" | grep -qE ".+@.+\..+"; do echo "\`$fulladdr\` is not a valid email address. Please retype the address:" read -r fulladdr done - grep -q "Channel\s*$fulladdr$" "$mbsyncrc" && + grep -q "Channel\s*$fulladdr$" "$mbsyncrc" 2>/dev/null && { echo "$fulladdr has already been added" && exit 1 ;} { [ -z "$imap" ] || [ -z "$smtp" ] ;} && parsedomains [ -z "$imap" ] && echo "Give your email server's IMAP address (excluding the port number):" && @@ -192,14 +188,11 @@ askinfo() { \ fi } -createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$pass_prefix$fulladdr" - "$GPG" -qer "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" "$PASSWORD_STORE_DIR/$pass_prefix$fulladdr" - rm -f "$PASSWORD_STORE_DIR/$pass_prefix$fulladdr" ;} - -writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr" +createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$fulladdr" + "$GPG" -qer "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" "$PASSWORD_STORE_DIR/$fulladdr" + rm -f "$PASSWORD_STORE_DIR/$fulladdr" ;} - # Get accounts and find the first missing account number (max. 9). - getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "$x" || { export idnum="$x"; break ;}; done +writeinfo() { mkdir -p "${muttrc%/*}" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr" # Configure msmtprc for sending mail. [ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc" @@ -213,37 +206,32 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_ # Create a muttrc for viewing mail. echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc" [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" - ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig $marker" >> "$muttrc" - ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc $marker" >> "$muttrc" - echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\" $marker" >> "$muttrc" + ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig" >> "$muttrc" + ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc" >> "$muttrc" + echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\"" >> "$muttrc" notmuchauto # Create a notmuch config file if not present already. } -getpass() { while : ; do pass rm -f "$pass_prefix$fulladdr" >/dev/null 2>&1 - pass insert "$pass_prefix$fulladdr" && break; done ;} +getpass() { while : ; do pass rm -f "$fulladdr" >/dev/null 2>&1 + pass insert "$fulladdr" && break; done ;} formatShortcut() { toappend="$toappend -macro index,pager g$1 \"=$3\" \"go to $2\" $marker -macro index,pager M$1 \";=$3\" \"move mail to $2\" $marker -macro index,pager C$1 \";=$3\" \"copy mail to $2\" $marker" >> "$accdir/$idnum-$fulladdr.muttrc" ;} +macro index,pager g$1 \"=$3\" \"go to $2\" +macro index,pager M$1 \";=$3\" \"move mail to $2\" +macro index,pager C$1 \";=$3\" \"copy mail to $2\"" ;} setBox() { toappend="$toappend -set $1 = \"+$2\" $marker" ;} - -getboxes() { [ -n "${force+x}" ] && mailboxes="INBOX -Drafts -Junk -Trash -Sent -Archive" && return 0 - info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap:${iport:-993}")" - [ -z "$info" ] && echo "Log-on not successful." && return 1 - mailboxes="$(echo "$info" | sed "s/.*\" //;s/\"//g" | tr -d ' ')" -} +set $1 = \"+$2\"" ;} -finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" - sed -ibu "/$marker/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu" +getboxes() { if [ -n "${force+x}" ]; then + mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" + else + info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $fulladdr)" --url "${protocol:-imaps}://$imap:${iport:-993}")" + [ -z "$info" ] && echo "Log-on not successful." && return 1 + mailboxes="$(echo "$info" | sed "s/.*\" //;s/\"//g" | tr -d ' ')" + fi + getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" for x in $mailboxes; do case "$x" in @@ -253,9 +241,12 @@ finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur *[Jj][Uu][Nn][Kk]*) formatShortcut j junk "$x" ;; *[Aa][Rr][Cc][Hh][Ii][Vv][Ee]*) formatShortcut a archive "$x" ;; *[Ss][Pp][Aa][Mm]*) formatShortcut S spam "$x" ;; - *[Ii][Nn][Bb][Oo][Xx]*) formatShortcut i inbox "$x"; setBox spoolfile "$x" ;; + *[Ii][Nn][Bb][Oo][Xx]*) formatShortcut i inbox "$x"; setBox spoolfile "$x" inbox="$x" ;; esac done +} + +finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" [ -z "${online+x}" ] && echo "$fulladdr (account #$idnum) added successfully." command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" @@ -328,7 +319,7 @@ Options allowed with -a: NOTE: Once at least one account is added, you can run \`mbsync -a\` to begin downloading mail. -To change an account's password, run \`pass edit ${pass_prefix}your@email.com\`. +To change an account's password, run \`pass edit your@email.com\`. EOF } @@ -365,7 +356,7 @@ esac done case "$action" in list) list ;; - add) checkbasics && askinfo && getprofiles && writeinfo && getboxes && finalize || { delete ; exit 1 ;} ;; + add) checkbasics && askinfo && getboxes && getprofiles && writeinfo && finalize || { delete ; exit 1 ;} ;; delete) delete ;; sync) mailsync $fulladdr ;; toggle) togglecron ;; -- cgit v1.2.3 From ea98dd667835c9b2f30bd05342aac3cc2aa199ba Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 30 Jan 2021 22:00:15 -0500 Subject: fix #606 --- bin/mw | 1 + 1 file changed, 1 insertion(+) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index cf42822..bcac4ea 100755 --- a/bin/mw +++ b/bin/mw @@ -118,6 +118,7 @@ bind index,pager g noop bind index,pager M noop bind index,pager C noop bind index gg first-entry +unset signature unmacro index o unmailboxes * " -- cgit v1.2.3 From 06ec18b8a6d624f3b342fe5173d1ca5a48bea7ab Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 5 Feb 2021 11:41:35 -0500 Subject: fix #643 --- bin/mw | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index bcac4ea..03abc4d 100755 --- a/bin/mw +++ b/bin/mw @@ -48,7 +48,8 @@ user $login passwordeval \"pass $fulladdr\" $tlsline " -mbsync_profile="IMAPStore $fulladdr-remote +mbsync_profile=" +IMAPStore $fulladdr-remote Host $imap Port ${iport:-993} User $login -- cgit v1.2.3 From a95ff5a471a991ba3acfc5995141fef85a37209a Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 5 Feb 2021 12:29:06 -0500 Subject: no longer flatten mailboxes at all, fix #648 --- bin/mw | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 03abc4d..e8d02f1 100755 --- a/bin/mw +++ b/bin/mw @@ -62,7 +62,6 @@ MaildirStore $fulladdr-local Subfolders Verbatim Path ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/ Inbox ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-INBOX} -Flatten _ Channel $fulladdr Expunge Both @@ -231,7 +230,7 @@ getboxes() { if [ -n "${force+x}" ]; then else info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $fulladdr)" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && echo "Log-on not successful." && return 1 - mailboxes="$(echo "$info" | sed "s/.*\" //;s/\"//g" | tr -d ' ')" + mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d ' ')" fi getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" -- cgit v1.2.3 From ddbf60ac093cab27d01497a5f0cfd44d4a3c0d5a Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 5 Feb 2021 15:08:28 -0500 Subject: prepare for addition of pop (not finished) --- bin/mw | 147 +++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 70 insertions(+), 77 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index e8d02f1..23d9e68 100755 --- a/bin/mw +++ b/bin/mw @@ -10,6 +10,7 @@ accdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/accounts" msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" msmtplog="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/msmtp.log" mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" +mpoprc="${XDG_CONFIG_HOME:-$HOME/.config}/mpop/config" alias mbsync='mbsync -c "$mbsyncrc"' for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/"; do @@ -28,27 +29,23 @@ getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "[0- list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" ;} -getprofiles() { \ - unset msmtp_header msmtp_profile mutt_profile mbsync_profile - case "$iport" in - 1143) imapssl=None ;; - 143) imapssl=STARTTLS ;; - esac -msmtp_header="defaults -auth on -tls on -tls_trust_file $sslcert -logfile $msmtplog -" -msmtp_profile="account $fulladdr +prepmsmtp() { echo "account $fulladdr host $smtp port ${sport:-587} from $fulladdr user $login passwordeval \"pass $fulladdr\" -$tlsline -" -mbsync_profile=" +auth on +${tlsline:-tls on} +tls_trust_file $sslcert +logfile $msmtplog +" >> "$msmtprc" + # On Ubuntu/Debian, a link is needed since they use an older version. + command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null +} + +prepmbsync() { mkdir -p "${mbsyncrc%/*}" + echo " IMAPStore $fulladdr-remote Host $imap Port ${iport:-993} @@ -73,56 +70,71 @@ SyncState * MaxMessages ${maxmes:-0} ExpireUnread no # End profile -" +" >> "$mbsyncrc" ;} + +prepmpop() { echo " +account $fulladdr +tls on +user $login +host $imap +delivery maildir ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-INBOX} +passwordeval pass $fulladdr +" >> "$mpoprc" ;} -if [ -z "${online+x}" ]; then -mutt_profile="# vim: filetype=neomuttrc +prepmutt() { echo "# vim: filetype=neomuttrc # muttrc file for account $fulladdr set realname = \"$realname\" set from = \"$fulladdr\" set sendmail = \"msmtp -a $fulladdr\" alias me $realname <$fulladdr> -set folder = \"$maildir/$fulladdr\" +set folder = \"$folder\" set header_cache = $cachedir/$fulladdr/headers set message_cachedir = $cachedir/$fulladdr/bodies set mbox_type = Maildir +$extra bind index,pager gg noop bind index,pager g noop bind index,pager M noop bind index,pager C noop bind index gg first-entry -macro index o \"mw -y $fulladdr\" \"run mbsync to sync $fulladdr\" unmailboxes * unalternates * -" -else -mutt_profile="# vim: filetype=neomuttrc -# muttrc file for account $fulladdr -set realname = \"$realname\" -set from = \"$fulladdr\" -set sendmail = \"msmtp -a $fulladdr\" -alias me $realname <$fulladdr> -set folder = \"imaps://$login@$imap:${iport:-993}\" -set imap_user = \"$login\" -set header_cache = $cachedir/$fulladdr/headers -set message_cachedir = $cachedir/$fulladdr/bodies -set imap_pass = \"\`pass $fulladdr\`\" +unset signature +unmacro index o +$synccmd +" > "$accdir/$idnum-$fulladdr.muttrc" -set mbox_type = Maildir + [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" + ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig" >> "$muttrc" + ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc" >> "$muttrc" + echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\"" >> "$muttrc" +} + +getprofiles() { \ + mkdir -p "${muttrc%/*}" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" + unset msmtp_header msmtp_profile mutt_profile mbsync_profile + case "$iport" in + 1143) imapssl=None ;; + 143) imapssl=STARTTLS ;; + esac + case "$type" in + online) folder="imaps://$login@$imap:${iport:-993}" +extra="set imap_user = \"$login\" +set imap_pass = \"\`pass $fulladdr\`\" set ssl_starttls = yes -set ssl_force_tls = yes +set ssl_force_tls = yes" + ;; + pop) synccmd="macro index o \"mpop $fulladdr\" \"run mpop to get $fulladdr's mail\"" + prepmpop ;; + *) synccmd="macro index o \"mw -y $fulladdr\" \"run mbsync to sync $fulladdr\"" + folder="$maildir/$fulladdr" + prepmbsync ;; + esac + prepmsmtp + prepmutt -bind index,pager gg noop -bind index,pager g noop -bind index,pager M noop -bind index,pager C noop -bind index gg first-entry -unset signature -unmacro index o -unmailboxes * -" -fi + prepnotmuch # Create a notmuch config file if not present already. } parsedomains(){ serverinfo="$(grep "^${fulladdr#*@}" "$muttshare/domains.csv" 2>/dev/null)" @@ -172,7 +184,7 @@ askinfo() { \ echo "\`$fulladdr\` is not a valid email address. Please retype the address:" read -r fulladdr done - grep -q "Channel\s*$fulladdr$" "$mbsyncrc" 2>/dev/null && + getaccounts; echo "$accounts" | grep -q "\s$fulladdr$" 2>/dev/null && { echo "$fulladdr has already been added" && exit 1 ;} { [ -z "$imap" ] || [ -z "$smtp" ] ;} && parsedomains [ -z "$imap" ] && echo "Give your email server's IMAP address (excluding the port number):" && @@ -193,27 +205,6 @@ createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$fulladdr" "$GPG" -qer "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" "$PASSWORD_STORE_DIR/$fulladdr" rm -f "$PASSWORD_STORE_DIR/$fulladdr" ;} -writeinfo() { mkdir -p "${muttrc%/*}" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" "$maildir/$fulladdr" - - # Configure msmtprc for sending mail. - [ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc" - echo "$msmtp_profile" >> "$msmtprc" - # On Ubuntu/Debian, a link is needed since they use an older version. - command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null - - # Create the mbsync config file if local account. - [ -z "${online+x}" ] && mkdir -p "${mbsyncrc%/*}" && echo "$mbsync_profile" >> "$mbsyncrc" - - # Create a muttrc for viewing mail. - echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc" - [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" - ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig" >> "$muttrc" - ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc" >> "$muttrc" - echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\"" >> "$muttrc" - - notmuchauto # Create a notmuch config file if not present already. -} - getpass() { while : ; do pass rm -f "$fulladdr" >/dev/null 2>&1 pass insert "$fulladdr" && break; done ;} @@ -247,13 +238,13 @@ getboxes() { if [ -n "${force+x}" ]; then done } -finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" - echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" - [ -z "${online+x}" ] && echo "$fulladdr (account #$idnum) added successfully." +finalize() { echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" + [ "$type" != "online" ] && echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" + echo "$fulladdr (account #$idnum) added successfully." command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" return 0 ;} -notmuchauto() { \ +prepnotmuch() { \ [ -z "$NOTMUCH_CONFIG" ] && NOTMUCH_CONFIG="$HOME/.notmuch-config" [ -f "$NOTMUCH_CONFIG" ] && return 0 nmbasic="[database] @@ -308,12 +299,13 @@ Main actions: Options allowed with -a: -u Account login name if not full address -n "Real name" to be on the email account - -i IMAP server address - -I IMAP server port + -i IMAP/POP server address + -I IMAP/POP server port -s SMTP server address -S SMTP server port -x Password for account (recommended to be in double quotes) -p Install for a Protonmail account. + -P Add for a POP server instead of IMAP -o Configure address, but keep mail online. -f Assume typical English mailboxes without attempting log-on. @@ -324,7 +316,7 @@ To change an account's password, run \`pass edit your@email.com\`. EOF } -while getopts "fplhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in +while getopts "fpPlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in l) setact list || exit 1 ;; d) setact delete || exit 1 ;; D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; @@ -338,7 +330,8 @@ while getopts "fplhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in u) setact add || exit 1 ; login="$OPTARG" ;; n) setact add || exit 1 ; realname="$OPTARG" ;; m) setact add || exit 1 ; maxmes="$OPTARG" ;; - o) setact add || exit 1 ; online=True ;; + o) setact add || exit 1 ; type="online" ;; + P) setact add || exit 1 ; type="pop" ;; f) setact add || exit 1 ; force=True ;; x) setact add || exit 1 ; password="$OPTARG" ;; t) setact toggle || exit 1 ; cronmin="$OPTARG" ;; @@ -357,7 +350,7 @@ esac done case "$action" in list) list ;; - add) checkbasics && askinfo && getboxes && getprofiles && writeinfo && finalize || { delete ; exit 1 ;} ;; + add) checkbasics && askinfo && getboxes && getprofiles && finalize || { delete ; exit 1 ;} ;; delete) delete ;; sync) mailsync $fulladdr ;; toggle) togglecron ;; -- cgit v1.2.3 From 1e7a2fa0d33d27894dfb7d574610855424dba2f7 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 5 Feb 2021 15:22:16 -0500 Subject: -X to delete local mail when deleting account --- bin/mw | 7 +++++-- mw.1 | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 23d9e68..58b5f0f 100755 --- a/bin/mw +++ b/bin/mw @@ -169,6 +169,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu pass rm -f "$fulladdr" >/dev/null 2>&1 + [ -n "${purge+x}" ] && rm -rf "${maildir:?}/${fulladdr:?}" # Get rid of those multiple newlines because I don't know awk well enough to do it by default lol. for file in "$msmtprc" "$mbsyncrc"; do @@ -305,7 +306,8 @@ Options allowed with -a: -S SMTP server port -x Password for account (recommended to be in double quotes) -p Install for a Protonmail account. - -P Add for a POP server instead of IMAP + -P Add for a POP server instead of IMAP. + -X Delete an account's local email too when deleting. -o Configure address, but keep mail online. -f Assume typical English mailboxes without attempting log-on. @@ -316,7 +318,7 @@ To change an account's password, run \`pass edit your@email.com\`. EOF } -while getopts "fpPlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in +while getopts "fpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in l) setact list || exit 1 ;; d) setact delete || exit 1 ;; D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; @@ -334,6 +336,7 @@ while getopts "fpPlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in P) setact add || exit 1 ; type="pop" ;; f) setact add || exit 1 ; force=True ;; x) setact add || exit 1 ; password="$OPTARG" ;; + X) setact delete || exit 1 ; purge=True ;; t) setact toggle || exit 1 ; cronmin="$OPTARG" ;; T) setact toggle || exit 1 ;; p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." diff --git a/mw.1 b/mw.1 index 6e971c2..a9ea0bd 100644 --- a/mw.1 +++ b/mw.1 @@ -79,6 +79,13 @@ connection will still be attempted in setup to discover mailboxes. .TP .B -p Add a Protonmail account. Protonmail Bridge must be installed and set up. +.TP +.B -X +When removing an email profile with either +.I -d +or +.I -D, +also delete the local mail (will not delete the mail on the server). .SH DETAILS .TP .B mailsync -- cgit v1.2.3 From d6d241a5fdab1329f3d7e7b212346d4c336f223c Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 5 Feb 2021 16:25:40 -0500 Subject: POP support added with mpop. Closes #609 --- README.md | 4 ++++ bin/mw | 26 +++++++++++++++----------- mw.1 | 14 ++++++++++++-- 3 files changed, 31 insertions(+), 13 deletions(-) (limited to 'bin/mw') diff --git a/README.md b/README.md index 93bbf0a..2aee255 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ A user of Arch-based distros can also install the current mutt-wizard release fr - `urlview` - outputs urls in mail to browser. - `cronie` - (or any other major cronjob manager) to set up automatic mail syncing. +- `mpop` - If you want to use POP protocol instead of IMAP. ## Usage @@ -101,6 +102,7 @@ The mutt-wizard runs via the command `mw`. Once setup is complete, you'll use - `-f` -- Assume mailbox names and force account configuration without connecting online at all. - `-o` -- Configure mutt for an account, but do not keep mail offline. +- `-P` -- Use POP protocol instead of IMAP (requires `mpop` installed). ## Neomutt user interface @@ -163,6 +165,8 @@ To give you an example of the interface, here's an idea: - Error handling for the many people who don't read or follow directions. Fewer errors generally. - Addition of a manual `man mw` +- Now handles POP protocol via `mpop` for those who prefer it (add an account + with the `-P` option). POP configs are still generated automatically. ## Help the Project! diff --git a/bin/mw b/bin/mw index 58b5f0f..129cda2 100755 --- a/bin/mw +++ b/bin/mw @@ -27,7 +27,7 @@ checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} -list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" ;} +list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" || exit 1 ;} prepmsmtp() { echo "account $fulladdr host $smtp @@ -72,7 +72,8 @@ ExpireUnread no # End profile " >> "$mbsyncrc" ;} -prepmpop() { echo " +prepmpop() { mkdir -p "${mpoprc%/*}" + echo " account $fulladdr tls on user $login @@ -126,6 +127,7 @@ set ssl_starttls = yes set ssl_force_tls = yes" ;; pop) synccmd="macro index o \"mpop $fulladdr\" \"run mpop to get $fulladdr's mail\"" + folder="$maildir/$fulladdr" prepmpop ;; *) synccmd="macro index o \"mw -y $fulladdr\" \"run mbsync to sync $fulladdr\"" folder="$maildir/$fulladdr" @@ -152,7 +154,7 @@ EOF delete() { if [ -z "${fulladdr+x}" ]; then echo "Select the account your would like to delete (by number):" - list + list || exit 1 read -r input match="^$input:" else @@ -162,18 +164,19 @@ delete() { if [ -z "${fulladdr+x}" ]; then fulladdr="$(echo "$accounts" | grep "$match" | cut -f2 -d' ')" - [ -z "$fulladdr" ] && echo "Invalid account name given." && return 1 + [ -z "$fulladdr" ] && echo "$fulladdr is not a valid account name." && return 1 - sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu + sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" 2>/dev/null ; rm -f "$mbsyncrc"bu rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc" - sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu - sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu + sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu + sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu + sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu pass rm -f "$fulladdr" >/dev/null 2>&1 [ -n "${purge+x}" ] && rm -rf "${maildir:?}/${fulladdr:?}" # Get rid of those multiple newlines because I don't know awk well enough to do it by default lol. - for file in "$msmtprc" "$mbsyncrc"; do - tr '\n' '|' < "$file" | sed "s/||\+/||/g" | tr '|' '\n' >> "$file"bu + for file in "$msmtprc" "$mbsyncrc" "$mpoprc"; do + tr '\n' '|' < "$file" 2>/dev/null | sed "s/||\+/||/g" | tr '|' '\n' >> "$file"bu mv -f "$file"bu "$file" done } @@ -217,13 +220,14 @@ macro index,pager C$1 \";=$3\" \"copy mail to $2\"" ;} setBox() { toappend="$toappend set $1 = \"+$2\"" ;} -getboxes() { if [ -n "${force+x}" ]; then +getboxes() { if [ -n "${force+x}" ] ; then mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" else info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $fulladdr)" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && echo "Log-on not successful." && return 1 mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d ' ')" fi + [ "$type" = "pop" ] && mailboxes="INBOX" getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" for x in $mailboxes; do @@ -333,7 +337,7 @@ while getopts "fpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in n) setact add || exit 1 ; realname="$OPTARG" ;; m) setact add || exit 1 ; maxmes="$OPTARG" ;; o) setact add || exit 1 ; type="online" ;; - P) setact add || exit 1 ; type="pop" ;; + P) setact add || exit 1 ; type="pop"; protocol="pop3s" ; iport="${iport:-995}" ;; f) setact add || exit 1 ; force=True ;; x) setact add || exit 1 ; password="$OPTARG" ;; X) setact delete || exit 1 ; purge=True ;; diff --git a/mw.1 b/mw.1 index a9ea0bd..26d9569 100644 --- a/mw.1 +++ b/mw.1 @@ -54,10 +54,10 @@ Real name which will appear in emails. Should be put in quotes if multiple words Set a maximum number of messages to be stored offline. .TP .B -i -IMAP server address +IMAP/POP server address .TP .B -I -IMAP server port (assumed to be 993 if not specified) +IMAP/POP server port (assumed to be 993 for IMAP and 995 for POP if not specified) .TP .B -s SMTP server address @@ -86,6 +86,15 @@ When removing an email profile with either or .I -D, also delete the local mail (will not delete the mail on the server). +.TP +.B -P +Use POP protocol instead of IMAP. Requires +.I mpop +to download mail after configuration. Server details can still be given with the +.I -i +and +.I -I +options as if it were a IMAP. .SH DETAILS .TP .B mailsync @@ -287,6 +296,7 @@ GPLv3 .BR neomutt (1), .BR neomuttrc (1) .BR mbsync (1), +.BR mpop (1), .BR msmtp (1), .BR notmuch (1), .BR abook (1) -- cgit v1.2.3 From 423112a3ab31806f9c6a6c075b9cceaf31139583 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 11 Feb 2021 10:29:44 -0500 Subject: minor improvement of regex --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 129cda2..0da655e 100755 --- a/bin/mw +++ b/bin/mw @@ -184,7 +184,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then askinfo() { \ [ -z "$fulladdr" ] && echo "Give the full email address to add:" && read -r fulladdr - while ! echo "$fulladdr" | grep -qE ".+@.+\..+"; do + while ! echo "$fulladdr" | grep -qE "^.+@.+\.[A-z]+$"; do echo "\`$fulladdr\` is not a valid email address. Please retype the address:" read -r fulladdr done -- cgit v1.2.3 From 7413dc6d5ad1fd85e316e49d0492d8e945162a4a Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 11 Feb 2021 11:54:54 -0500 Subject: since logons check before, delete not nec w/ error --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 0da655e..d869a30 100755 --- a/bin/mw +++ b/bin/mw @@ -153,7 +153,7 @@ EOF } delete() { if [ -z "${fulladdr+x}" ]; then - echo "Select the account your would like to delete (by number):" + echo "Select the account you would like to delete (by number):" list || exit 1 read -r input match="^$input:" @@ -357,7 +357,7 @@ esac done case "$action" in list) list ;; - add) checkbasics && askinfo && getboxes && getprofiles && finalize || { delete ; exit 1 ;} ;; + add) checkbasics && askinfo && getboxes && getprofiles && finalize ;; delete) delete ;; sync) mailsync $fulladdr ;; toggle) togglecron ;; -- cgit v1.2.3 From fff2625e77064e639278bcb611ac11ab7fa03126 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 11 Feb 2021 13:05:02 -0500 Subject: minor --- bin/mw | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index d869a30..501f2e3 100755 --- a/bin/mw +++ b/bin/mw @@ -3,7 +3,6 @@ prefix="/usr/local" maildir="${XDG_DATA_HOME:-$HOME/.local/share}/mail" muttshare="$prefix/share/mutt-wizard" -mwconfig="$muttshare/mutt-wizard.muttrc" cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard" muttrc="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/muttrc" accdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/accounts" @@ -107,8 +106,8 @@ $synccmd " > "$accdir/$idnum-$fulladdr.muttrc" [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" - ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $mwconfig" >> "$muttrc" - ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$mwconfig" && echo "source $accdir/$idnum-$fulladdr.muttrc" >> "$muttrc" + ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $muttshare/mutt-wizard.muttrc" >> "$muttrc" + ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$muttshare/mutt-wizard.muttrc" && echo "source $accdir/$idnum-$fulladdr.muttrc" >> "$muttrc" echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\"" >> "$muttrc" } @@ -210,7 +209,7 @@ createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$fulladdr" rm -f "$PASSWORD_STORE_DIR/$fulladdr" ;} getpass() { while : ; do pass rm -f "$fulladdr" >/dev/null 2>&1 - pass insert "$fulladdr" && break; done ;} + pass insert -f "$fulladdr" && break; done ;} formatShortcut() { toappend="$toappend macro index,pager g$1 \"=$3\" \"go to $2\" @@ -223,7 +222,7 @@ set $1 = \"+$2\"" ;} getboxes() { if [ -n "${force+x}" ] ; then mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" else - info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $fulladdr)" --url "${protocol:-imaps}://$imap:${iport:-993}")" + info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && echo "Log-on not successful." && return 1 mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d ' ')" fi -- cgit v1.2.3 From 4d411d81798f652fcdfd55d866c4e78f8867a9bc Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 26 Feb 2021 12:37:13 -0500 Subject: avoid regex issue --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 501f2e3..111c8d5 100755 --- a/bin/mw +++ b/bin/mw @@ -183,7 +183,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then askinfo() { \ [ -z "$fulladdr" ] && echo "Give the full email address to add:" && read -r fulladdr - while ! echo "$fulladdr" | grep -qE "^.+@.+\.[A-z]+$"; do + while ! echo "$fulladdr" | grep -qE "^.+@.+\.[A-Za-z]+$"; do echo "\`$fulladdr\` is not a valid email address. Please retype the address:" read -r fulladdr done -- cgit v1.2.3 From 2230c4153aaf5301984a94709e0c8dabf9b956a6 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 4 Mar 2021 08:22:52 -0500 Subject: protonmail smtp, fix #667 --- bin/mw | 5 +++-- share/domains.csv | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 111c8d5..2989717 100755 --- a/bin/mw +++ b/bin/mw @@ -34,7 +34,7 @@ port ${sport:-587} from $fulladdr user $login passwordeval \"pass $fulladdr\" -auth on +auth ${auth:-on} ${tlsline:-tls on} tls_trust_file $sslcert logfile $msmtplog @@ -175,7 +175,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then # Get rid of those multiple newlines because I don't know awk well enough to do it by default lol. for file in "$msmtprc" "$mbsyncrc" "$mpoprc"; do - tr '\n' '|' < "$file" 2>/dev/null | sed "s/||\+/||/g" | tr '|' '\n' >> "$file"bu + tr '\n' '|' 2>/dev/null < "$file" | sed "s/||\+/||/g" | tr '|' '\n' >> "$file"bu mv -f "$file"bu "$file" done } @@ -348,6 +348,7 @@ while getopts "fpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in iport="1143" smtp="127.0.0.1" sport="1025" + auth="login" tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | awk '/SHA256:/ {print $2}')" setact add || exit 1 ;; diff --git a/share/domains.csv b/share/domains.csv index 6550c34..9fa473c 100644 --- a/share/domains.csv +++ b/share/domains.csv @@ -83,8 +83,8 @@ distruzione.org,mail.autistici.org,993,smtp.autistici.org,465 dorriseaton.com,outlook.office365.com,993,smtp.office365.com,587 dr.com,imap.mail.com,993,smtp.mail.com,587 duke.edu,outlook.office365.com,993,smtp.office365.com,587 -e.email,mail.ecloud.global,993.00,mail.ecloud.global,587.00 -e.email,mail.ecloud.global,993.00,mail.ecloud.global,587.00 +e.email,mail.ecloud.global,993,mail.ecloud.global,587 +e.email,mail.ecloud.global,993,mail.ecloud.global,587 email.arizona.edu,imap.gmail.com,993,smtp.gmail.com,587 email.com,imap.mail.com,993,smtp.mail.com,587 eneco.com,outlook.office365.com,993,smtp.office365.com,587 -- cgit v1.2.3 From c95428f0f1c02fba4b13a4ec43c70d9e892c52dd Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 11 Mar 2021 17:20:04 -0500 Subject: compliance with libtard upstream --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 2989717..43bb4d6 100755 --- a/bin/mw +++ b/bin/mw @@ -61,8 +61,8 @@ Inbox ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-INBOX} Channel $fulladdr Expunge Both -Master :$fulladdr-remote: -Slave :$fulladdr-local: +Far :$fulladdr-remote: +Near :$fulladdr-local: Patterns * !\"[Gmail]/All Mail\" Create Both SyncState * -- cgit v1.2.3 From c9419f72b0750bbd205e36dfa0fc64e12cdbad20 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 19 Mar 2021 08:14:09 -0400 Subject: Revert "compliance with libtard upstream" This reverts commit c95428f0f1c02fba4b13a4ec43c70d9e892c52dd. --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 43bb4d6..2989717 100755 --- a/bin/mw +++ b/bin/mw @@ -61,8 +61,8 @@ Inbox ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-INBOX} Channel $fulladdr Expunge Both -Far :$fulladdr-remote: -Near :$fulladdr-local: +Master :$fulladdr-remote: +Slave :$fulladdr-local: Patterns * !\"[Gmail]/All Mail\" Create Both SyncState * -- cgit v1.2.3 From b5cde63ada77f24703cbba141909ba45d5161a1f Mon Sep 17 00:00:00 2001 From: João Vanzuita Date: Fri, 26 Mar 2021 13:34:57 +0100 Subject: fix: update mbsync call for macos --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 2989717..54b4a61 100755 --- a/bin/mw +++ b/bin/mw @@ -128,7 +128,7 @@ set ssl_force_tls = yes" pop) synccmd="macro index o \"mpop $fulladdr\" \"run mpop to get $fulladdr's mail\"" folder="$maildir/$fulladdr" prepmpop ;; - *) synccmd="macro index o \"mw -y $fulladdr\" \"run mbsync to sync $fulladdr\"" + *) synccmd="macro index o \"mbsync -a $fulladdr\" \"run mbsync to sync $fulladdr\"" folder="$maildir/$fulladdr" prepmbsync ;; esac -- cgit v1.2.3 From b95d5f2810d518a70ce934d3644aa7e8fde13af3 Mon Sep 17 00:00:00 2001 From: João Vanzuita Date: Fri, 26 Mar 2021 20:38:28 +0100 Subject: chore: typo --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 54b4a61..2b5563f 100755 --- a/bin/mw +++ b/bin/mw @@ -128,7 +128,7 @@ set ssl_force_tls = yes" pop) synccmd="macro index o \"mpop $fulladdr\" \"run mpop to get $fulladdr's mail\"" folder="$maildir/$fulladdr" prepmpop ;; - *) synccmd="macro index o \"mbsync -a $fulladdr\" \"run mbsync to sync $fulladdr\"" + *) synccmd="macro index o \"mbsync $fulladdr\" \"run mbsync to sync $fulladdr\"" folder="$maildir/$fulladdr" prepmbsync ;; esac -- cgit v1.2.3 From 5e582be7dd1cd8ed91b5150df42577e5ec7ffdd8 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 2 Apr 2021 12:42:56 -0400 Subject: stave off using unmacro for debian, fix #699 --- bin/mw | 1 - 1 file changed, 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 2989717..4ecbcfa 100755 --- a/bin/mw +++ b/bin/mw @@ -101,7 +101,6 @@ bind index gg first-entry unmailboxes * unalternates * unset signature -unmacro index o $synccmd " > "$accdir/$idnum-$fulladdr.muttrc" -- cgit v1.2.3 From 39cc3a7e37a832ab3ff092eb3f7d9b710fdbbcb7 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 4 May 2021 10:48:37 -0400 Subject: fix #713, don't detect non-inbox as inbox --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 4ecbcfa..0c31c00 100755 --- a/bin/mw +++ b/bin/mw @@ -236,7 +236,7 @@ getboxes() { if [ -n "${force+x}" ] ; then *[Jj][Uu][Nn][Kk]*) formatShortcut j junk "$x" ;; *[Aa][Rr][Cc][Hh][Ii][Vv][Ee]*) formatShortcut a archive "$x" ;; *[Ss][Pp][Aa][Mm]*) formatShortcut S spam "$x" ;; - *[Ii][Nn][Bb][Oo][Xx]*) formatShortcut i inbox "$x"; setBox spoolfile "$x" inbox="$x" ;; + *[Ii][Nn][Bb][Oo][Xx]) formatShortcut i inbox "$x"; setBox spoolfile "$x" inbox="$x" ;; esac done } -- cgit v1.2.3 From 2cb2fa03452cb99537a1751961574a0b6d3253e0 Mon Sep 17 00:00:00 2001 From: Aisha Tammy Date: Sat, 15 May 2021 22:16:15 -0400 Subject: allow dynamically loading available mailboxes this way if a folder is added or deleted in the remote location, and gets deleted after sync, it is reflected in the next opening Signed-off-by: Aisha Tammy --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 54af276..ebd0fdb 100755 --- a/bin/mw +++ b/bin/mw @@ -227,7 +227,7 @@ getboxes() { if [ -n "${force+x}" ] ; then fi [ "$type" = "pop" ] && mailboxes="INBOX" getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done - toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" + toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -type d -name cur | sort | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | tr '\\\n' ' '\`" for x in $mailboxes; do case "$x" in *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; -- cgit v1.2.3 From 2a50561834c23565bd5587972dff5cc9de53dd57 Mon Sep 17 00:00:00 2001 From: Aisha Tammy Date: Wed, 19 May 2021 18:57:43 -0400 Subject: set mindepth to 1 and move sort to after sed Signed-off-by: Aisha Tammy --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index ebd0fdb..3cc3d78 100755 --- a/bin/mw +++ b/bin/mw @@ -227,7 +227,7 @@ getboxes() { if [ -n "${force+x}" ] ; then fi [ "$type" = "pop" ] && mailboxes="INBOX" getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done - toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -type d -name cur | sort | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | tr '\\\n' ' '\`" + toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`" for x in $mailboxes; do case "$x" in *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; -- cgit v1.2.3 From 8c71c10b0a8066cf0dc6bc5e0c5583eaddbb5441 Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 25 May 2021 16:05:16 -0400 Subject: password store with multiple private keys fix --- bin/mw | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 54af276..92e539c 100755 --- a/bin/mw +++ b/bin/mw @@ -18,8 +18,7 @@ done || { echo "CA Certificate not found. Please install one or link it to /etc/ checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" PASSWORD_STORE_DIR="${PASSWORD_STORE_DIR:-$HOME/.password-store}" - [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && - "$GPG" --list-secret-keys "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" >/dev/null 2>&1 || { + [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] || { echo "First run \`pass init \` to set up a password archive." echo "(If you don't already have a GPG key pair, first run \`$GPG --full-generate-key\`.)" exit 1 ;} ;} @@ -204,7 +203,7 @@ askinfo() { \ } createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$fulladdr" - "$GPG" -qer "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" "$PASSWORD_STORE_DIR/$fulladdr" + "$GPG" -qe $(printf -- " -r %s" $(cat "$PASSWORD_STORE_DIR/.gpg-id")) "$PASSWORD_STORE_DIR/$fulladdr" rm -f "$PASSWORD_STORE_DIR/$fulladdr" ;} getpass() { while : ; do pass rm -f "$fulladdr" >/dev/null 2>&1 -- cgit v1.2.3 From f92000e5ed8d393de8f02093afebdb5ab69a1861 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 28 Jun 2021 10:25:41 -0400 Subject: fix #730, sed only nl removal with error sup --- bin/mw | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 54af276..d960b7b 100755 --- a/bin/mw +++ b/bin/mw @@ -172,10 +172,8 @@ delete() { if [ -z "${fulladdr+x}" ]; then pass rm -f "$fulladdr" >/dev/null 2>&1 [ -n "${purge+x}" ] && rm -rf "${maildir:?}/${fulladdr:?}" - # Get rid of those multiple newlines because I don't know awk well enough to do it by default lol. for file in "$msmtprc" "$mbsyncrc" "$mpoprc"; do - tr '\n' '|' 2>/dev/null < "$file" | sed "s/||\+/||/g" | tr '|' '\n' >> "$file"bu - mv -f "$file"bu "$file" + sed -ibu 'N;/^\n$/D;P;D;' "$file" 2>/dev/null; rm -f "$file"bu done } -- cgit v1.2.3 From 8171e6327c2c1b4088da441ced4186d0934bc888 Mon Sep 17 00:00:00 2001 From: phire Date: Thu, 8 Jul 2021 01:38:41 +0200 Subject: Set hostname variable --- bin/mw | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index d960b7b..0fd01d8 100755 --- a/bin/mw +++ b/bin/mw @@ -91,6 +91,7 @@ set folder = \"$folder\" set header_cache = $cachedir/$fulladdr/headers set message_cachedir = $cachedir/$fulladdr/bodies set mbox_type = Maildir +set hostname = \"$hostname\" $extra bind index,pager gg noop @@ -193,6 +194,7 @@ askinfo() { \ read -r smtp [ "$sport" = 465 ] && tlsline="tls_starttls off" [ -z "$realname" ] && realname="${fulladdr%%@*}" + hostname="$(echo "$fulladdr" | cut -d @ -f 2)" login="${login:-$fulladdr}" if [ -n "${password+x}" ]; then createpass -- cgit v1.2.3 From 8e5bb8bd095aaf9cb42997c243c4d4dc47f588a9 Mon Sep 17 00:00:00 2001 From: ananthu Date: Sat, 7 Aug 2021 14:14:15 +0530 Subject: bug; argument getting splitted by space --- bin/mw | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 0fd01d8..2e38cde 100755 --- a/bin/mw +++ b/bin/mw @@ -228,6 +228,7 @@ getboxes() { if [ -n "${force+x}" ] ; then [ "$type" = "pop" ] && mailboxes="INBOX" getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" + IFS=$'\n' for x in $mailboxes; do case "$x" in *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; @@ -239,6 +240,7 @@ getboxes() { if [ -n "${force+x}" ] ; then *[Ii][Nn][Bb][Oo][Xx]) formatShortcut i inbox "$x"; setBox spoolfile "$x" inbox="$x" ;; esac done + unset IFS } finalize() { echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" -- cgit v1.2.3 From 8239a7d5ca6807d395f787c8c940a08301eb61d7 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 9 Aug 2021 20:52:19 -0400 Subject: remove bashism, fix #752 --- bin/mw | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 2e38cde..41977b1 100755 --- a/bin/mw +++ b/bin/mw @@ -182,7 +182,7 @@ askinfo() { \ [ -z "$fulladdr" ] && echo "Give the full email address to add:" && read -r fulladdr while ! echo "$fulladdr" | grep -qE "^.+@.+\.[A-Za-z]+$"; do - echo "\`$fulladdr\` is not a valid email address. Please retype the address:" + echo "$fulladdr is not a valid email address. Please retype the address:" read -r fulladdr done getaccounts; echo "$accounts" | grep -q "\s$fulladdr$" 2>/dev/null && @@ -228,7 +228,8 @@ getboxes() { if [ -n "${force+x}" ] ; then [ "$type" = "pop" ] && mailboxes="INBOX" getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" - IFS=$'\n' + IFS=' +' for x in $mailboxes; do case "$x" in *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; -- cgit v1.2.3 From fb68f19846141df5ff5c6b8c4f15f589b0f5000f Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 14 Aug 2021 18:50:33 -0400 Subject: use soyterms if not slower distro --- bin/mw | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 41977b1..87ec79c 100755 --- a/bin/mw +++ b/bin/mw @@ -12,7 +12,18 @@ mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" mpoprc="${XDG_CONFIG_HOME:-$HOME/.config}/mpop/config" alias mbsync='mbsync -c "$mbsyncrc"' -for x in "/etc/ssl/certs/ca-certificates.crt" "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" "/etc/ssl/cert.pem" "/usr/local/share/ca-certificates/"; do +# On Ubuntu/Debian, a link is needed since they use an older version. +if command -V apt-get >/dev/null 2>&1; then + ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null + master="Master" + slave="Slave" +fi + +for x in "/etc/ssl/certs/ca-certificates.crt" \ + "/etc/pki/tls/certs/ca-bundle.crt" "/etc/ssl/cert.pem" \ + "/etc/ssl/ca-bundle.pem" "/etc/pki/tls/cacert.pem" \ + "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" \ + "/usr/local/share/ca-certificates/"; do [ -f "$x" ] && sslcert="$x" && break done || { echo "CA Certificate not found. Please install one or link it to /etc/ssl/certs/ca-certificates.crt" && exit 1 ;} @@ -39,8 +50,6 @@ ${tlsline:-tls on} tls_trust_file $sslcert logfile $msmtplog " >> "$msmtprc" - # On Ubuntu/Debian, a link is needed since they use an older version. - command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null } prepmbsync() { mkdir -p "${mbsyncrc%/*}" @@ -61,8 +70,8 @@ Inbox ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-INBOX} Channel $fulladdr Expunge Both -Master :$fulladdr-remote: -Slave :$fulladdr-local: +${master:-Far} :$fulladdr-remote: +${slave:-Near} :$fulladdr-local: Patterns * !\"[Gmail]/All Mail\" Create Both SyncState * -- cgit v1.2.3 From bd8551163ead2720fd3d3579f64f8816521be11c Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 27 Aug 2021 19:05:55 -0400 Subject: fix for 465 starttls --- bin/mw | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 87ec79c..fbf2884 100755 --- a/bin/mw +++ b/bin/mw @@ -46,9 +46,10 @@ from $fulladdr user $login passwordeval \"pass $fulladdr\" auth ${auth:-on} -${tlsline:-tls on} +tls on tls_trust_file $sslcert logfile $msmtplog +$tlsline " >> "$msmtprc" } -- cgit v1.2.3 From 2be8ea7871e6d07592d7b4ed85ace213774261f6 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sun, 29 Aug 2021 14:36:26 -0400 Subject: not necessary to create cachedir manually --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 823730e..e63fff2 100755 --- a/bin/mw +++ b/bin/mw @@ -121,7 +121,7 @@ $synccmd } getprofiles() { \ - mkdir -p "${muttrc%/*}" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" + mkdir -p "${muttrc%/*}" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" unset msmtp_header msmtp_profile mutt_profile mbsync_profile case "$iport" in 1143) imapssl=None ;; -- cgit v1.2.3 From e8458ace20a1e553df1c6249b9ef27234dd2aafd Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 23 Sep 2021 13:06:17 -0400 Subject: fix #691, fix #689, fix #690 --- Makefile | 4 ++-- bin/mw | 10 +--------- share/domains.csv | 2 +- share/unbind.muttrc | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 share/unbind.muttrc (limited to 'bin/mw') diff --git a/Makefile b/Makefile index 5cd5bf2..64036d0 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ install: chmod 755 $(DESTDIR)$(PREFIX)/bin/mw $(DESTDIR)$(PREFIX)/bin/mailsync $(DESTDIR)$(PREFIX)/bin/openfile mkdir -p $(DESTDIR)$(PREFIX)/share/mutt-wizard chmod 755 $(DESTDIR)$(PREFIX)/share/mutt-wizard - cp -f share/mailcap share/domains.csv share/mutt-wizard.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard - chmod 644 $(DESTDIR)$(PREFIX)/share/mutt-wizard/mailcap $(DESTDIR)$(PREFIX)/share/mutt-wizard/domains.csv $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrc + cp -f share/mailcap share/domains.csv share/mutt-wizard.muttrc share/unbind.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard + chmod 644 $(DESTDIR)$(PREFIX)/share/mutt-wizard/mailcap $(DESTDIR)$(PREFIX)/share/mutt-wizard/domains.csv $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard/unbind.muttrc mkdir -p $(DESTDIR)$(MANPREFIX)/man1 cp -f mw.1 $(DESTDIR)$(MANPREFIX)/man1/mw.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/mw.1 diff --git a/bin/mw b/bin/mw index e63fff2..2b9a41a 100755 --- a/bin/mw +++ b/bin/mw @@ -101,16 +101,8 @@ set header_cache = $cachedir/$fulladdr/headers set message_cachedir = $cachedir/$fulladdr/bodies set mbox_type = Maildir set hostname = \"$hostname\" +source $muttshare/unbind.muttrc $extra - -bind index,pager gg noop -bind index,pager g noop -bind index,pager M noop -bind index,pager C noop -bind index gg first-entry -unmailboxes * -unalternates * -unset signature $synccmd " > "$accdir/$idnum-$fulladdr.muttrc" diff --git a/share/domains.csv b/share/domains.csv index 672a1c6..e307b22 100644 --- a/share/domains.csv +++ b/share/domains.csv @@ -50,7 +50,7 @@ canaglie.net,mail.autistici.org,993,smtp.autistici.org,465 canaglie.org,mail.autistici.org,993,smtp.autistici.org,465 carleton.ca,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 cash4u.com,imap.mail.com,993,smtp.mail.com,587 -cedars.xyz,imap.cedars.xyz,993,smtp.cedars.xyz,465 +cedars.xyz,mail.cedars.xyz,993,mail.cedars.xyz,465 ceng.metu.edu.tr,imap.ceng.metu.edu.tr,993,mailhost.ceng.metu.edu.tr,587 cheerful.com,imap.mail.com,993,smtp.mail.com,587 chef.net,imap.mail.com,993,smtp.mail.com,587 diff --git a/share/unbind.muttrc b/share/unbind.muttrc new file mode 100644 index 0000000..330d823 --- /dev/null +++ b/share/unbind.muttrc @@ -0,0 +1,37 @@ +# vim: filetype=neomuttrc + +# This is an embarrassing and hacky file that unbinds a bunch of binds between +# switching accounts. It is called each time an account is changed. + +bind index,pager gi noop +bind index,pager gs noop +bind index,pager gd noop +bind index,pager ga noop +bind index,pager gS noop +bind index,pager gj noop +bind index,pager gt noop +bind index,pager Mi noop +bind index,pager Ms noop +bind index,pager Md noop +bind index,pager Ma noop +bind index,pager MS noop +bind index,pager Mj noop +bind index,pager Mt noop +bind index,pager Ci noop +bind index,pager Cs noop +bind index,pager Cd noop +bind index,pager Ca noop +bind index,pager CS noop +bind index,pager Cj noop +bind index,pager Ct noop +bind index,pager gg noop +bind index,pager g noop +bind index,pager M noop +bind index,pager C noop +unset hostname +unmy_hdr Organization +unmailboxes * +unalternates * +unset signature + +bind index gg first-entry -- cgit v1.2.3 From c88994e730a290e466565013e044bd0921fe6fbf Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 23 Sep 2021 13:31:07 -0400 Subject: decrease gnuisms --- bin/mailsync | 2 +- bin/mw | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'bin/mw') diff --git a/bin/mailsync b/bin/mailsync index bed86a9..9490458 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -14,7 +14,7 @@ # Run only if user logged in (prevent cron errors) pgrep -u "${USER:=$LOGNAME}" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;} # Run only if not already running in other instance -pidof mbsync >/dev/null && { echo "mbsync is already running."; exit ;} +pgrep mbsync >/dev/null && { echo "mbsync is already running."; exit ;} # First, we have to get the right variables for the mbsync file, the pass # archive, notmuch and the GPG home. This is done by searching common profile diff --git a/bin/mw b/bin/mw index 2b9a41a..204f6ee 100755 --- a/bin/mw +++ b/bin/mw @@ -129,7 +129,7 @@ set ssl_force_tls = yes" pop) synccmd="macro index o \"mpop $fulladdr\" \"run mpop to get $fulladdr's mail\"" folder="$maildir/$fulladdr" prepmpop ;; - *) synccmd="macro index o \"mbsync $fulladdr\" \"run mbsync to sync $fulladdr\"" + *) synccmd="macro index o \"mw -y $fulladdr\" \"run mbsync to sync $fulladdr\"" folder="$maildir/$fulladdr" prepmbsync ;; esac @@ -227,7 +227,7 @@ getboxes() { if [ -n "${force+x}" ] ; then mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d ' ')" fi [ "$type" = "pop" ] && mailboxes="INBOX" - getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done + getaccounts; for x in 1 2 3 4 5 6 7 8 9; do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" IFS=' ' -- cgit v1.2.3 From fcf4ba52c357ed05a2b6494c25ef3bab4d4e1c0e Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 23 Sep 2021 15:47:59 -0400 Subject: id numbers removed from filenames --- bin/mw | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index c0044e8..945b5de 100755 --- a/bin/mw +++ b/bin/mw @@ -34,7 +34,7 @@ checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" echo "(If you don't already have a GPG key pair, first run \`$GPG --full-generate-key\`.)" exit 1 ;} ;} -getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} +getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "\S*.muttrc" | sed "s|.*/\([0-9]-\)*||;s/\.muttrc$//" | nl)" ;} list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" || exit 1 ;} @@ -104,12 +104,12 @@ set hostname = \"$hostname\" source $muttshare/unbind.muttrc $extra $synccmd -" > "$accdir/$idnum-$fulladdr.muttrc" +" > "$accdir/$fulladdr.muttrc" [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $muttshare/mutt-wizard.muttrc" >> "$muttrc" - ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$muttshare/mutt-wizard.muttrc" && echo "source $accdir/$idnum-$fulladdr.muttrc" >> "$muttrc" - echo "macro index,pager i$idnum 'source $accdir/$idnum-$fulladdr.muttrc!;' \"switch to $fulladdr\"" >> "$muttrc" + ! grep "^source.*.muttrc" "$muttrc" | grep -qv "$muttshare/mutt-wizard.muttrc" && echo "source $accdir/$fulladdr.muttrc" >> "$muttrc" + echo "macro index,pager i$idnum 'source $accdir/$fulladdr.muttrc!;' \"switch to $fulladdr\"" >> "$muttrc" } getprofiles() { \ @@ -156,18 +156,18 @@ delete() { if [ -z "${fulladdr+x}" ]; then echo "Select the account you would like to delete (by number):" list || exit 1 read -r input - match="^$input:" + match="^\s*$input\s\+" else - match=" $fulladdr$" + match="\s\+$fulladdr$" getaccounts fi - fulladdr="$(echo "$accounts" | grep "$match" | cut -f2 -d' ')" + fulladdr="$(echo "$accounts" | grep "$match" | grep -o "\S*@\S*")" [ -z "$fulladdr" ] && echo "$fulladdr is not a valid account name." && return 1 sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" 2>/dev/null ; rm -f "$mbsyncrc"bu - rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc" + rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/$fulladdr.muttrc" "$accdir/"[0-9]-"$fulladdr.muttrc" sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu @@ -224,11 +224,15 @@ getboxes() { if [ -n "${force+x}" ] ; then else info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && echo "Log-on not successful." && return 1 - mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d ' -')" + mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" fi [ "$type" = "pop" ] && mailboxes="INBOX" - getaccounts; for x in 1 2 3 4 5 6 7 8 9; do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done + getaccounts + usednums="$(grep -o "^macro.* i[0-9]\+ " "$muttrc" | grep -o "[0-9]" | sort -u)" + for x in 1 2 3 4 5 6 7 8 9; do + echo "$usednums" | grep -q "$x" || + { export idnum="$x"; break ;} + done toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`" IFS=' ' @@ -246,7 +250,7 @@ getboxes() { if [ -n "${force+x}" ] ; then unset IFS } -finalize() { echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc" +finalize() { echo "$toappend" >> "$accdir/$fulladdr.muttrc" [ "$type" != "online" ] && echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" echo "$fulladdr (account #$idnum) added successfully." command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" -- cgit v1.2.3 From 8c668a22e09d4118a49bbd75bc3539c297289029 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 23 Sep 2021 16:04:28 -0400 Subject: lol --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 945b5de..6c7438e 100755 --- a/bin/mw +++ b/bin/mw @@ -168,7 +168,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" 2>/dev/null ; rm -f "$mbsyncrc"bu rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/$fulladdr.muttrc" "$accdir/"[0-9]-"$fulladdr.muttrc" - sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu + sed -ibu "/[0-9]-$fulladdr.muttrc/d" "/$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu pass rm -f "$fulladdr" >/dev/null 2>&1 -- cgit v1.2.3 From 7a792c7c11d315132a062c800b0a35cbccd9195d Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 23 Sep 2021 16:10:31 -0400 Subject: actual lol --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 6c7438e..051bf54 100755 --- a/bin/mw +++ b/bin/mw @@ -168,7 +168,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" 2>/dev/null ; rm -f "$mbsyncrc"bu rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/$fulladdr.muttrc" "$accdir/"[0-9]-"$fulladdr.muttrc" - sed -ibu "/[0-9]-$fulladdr.muttrc/d" "/$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu + sed -ibu "/\([0-9]-\)\?$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu pass rm -f "$fulladdr" >/dev/null 2>&1 -- cgit v1.2.3 From a3fc13e5ce54cd8d0e139e338ac75370e26c9184 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 23 Sep 2021 16:12:07 -0400 Subject: 465 now default instead of 587 --- README.md | 2 +- bin/mw | 6 +++--- mw.1 | 2 +- share/domains.csv | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'bin/mw') diff --git a/README.md b/README.md index 2aee255..a19170b 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ The mutt-wizard runs via the command `mw`. Once setup is complete, you'll use - `-i` -- IMAP server address - `-I` -- IMAP server port (otherwise assumed to be 993) - `-s` -- SMTP server address -- `-S` -- SMTP server port (otherwise assumed to be 587) +- `-S` -- SMTP server port (otherwise assumed to be 465) - `-m` -- Maximum number of emails to be kept offline. No maximum is default functionality. - `-x` -- Account password. You will be prompted for it otherwise. diff --git a/bin/mw b/bin/mw index 051bf54..8adb0b9 100755 --- a/bin/mw +++ b/bin/mw @@ -40,7 +40,7 @@ list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" || exit 1 ;} prepmsmtp() { echo "account $fulladdr host $smtp -port ${sport:-587} +port ${sport:-465} from $fulladdr user $login passwordeval \"pass $fulladdr\" @@ -48,7 +48,7 @@ auth ${auth:-on} tls on tls_trust_file $sslcert logfile $msmtplog -$tlsline +${tlsline:-tls_starttls off} " >> "$msmtprc" } @@ -193,7 +193,7 @@ askinfo() { \ read -r imap [ -z "$smtp" ] && echo "Give your email server's SMTP address (excluding the port number):" && read -r smtp - [ "$sport" = 465 ] && tlsline="tls_starttls off" + [ "$sport" = 587 ] && tlsline="# tls_starttls" [ -z "$realname" ] && realname="${fulladdr%%@*}" hostname="$(echo "$fulladdr" | cut -d @ -f 2)" login="${login:-$fulladdr}" diff --git a/mw.1 b/mw.1 index 26d9569..a8c5c8e 100644 --- a/mw.1 +++ b/mw.1 @@ -63,7 +63,7 @@ IMAP/POP server port (assumed to be 993 for IMAP and 995 for POP if not specifie SMTP server address .TP .B -S -SMTP server port (assumed to be 587 if not specified) +SMTP server port (assumed to be 465 if not specified) .TP .B -x Account password. You will be prompted for the password interactively if this option is not given. diff --git a/share/domains.csv b/share/domains.csv index e307b22..854d383 100644 --- a/share/domains.csv +++ b/share/domains.csv @@ -160,7 +160,7 @@ live.rhul.ac.uk,outlook.office365.com,993,smtp.office365.com,587 logorroici.org,mail.autistici.org,993,smtp.autistici.org,465 loves.dicksinhisan.us,mail.cock.li,993,mail.cock.li,587 loves.dicksinmyan.us,mail.cock.li,993,mail.cock.li,587 -lukesmith.xyz,mail.lukesmith.xyz,993,mail.lukesmith.xyz,587 +lukesmith.xyz,mail.lukesmith.xyz,993,mail.lukesmith.xyz,465 luther.edu,imap.gmail.com,993,smtp.gmail.com,587 mac.com,imap.mail.me.com,993,smtp.mail.me.com,587 mace.ac.in,imap.gmail.com,993,smtp.gmail.com,587 -- cgit v1.2.3 From b6f0bd44267ea5a5f46ab27d4786ca72ae3511cd Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 23 Sep 2021 19:56:58 -0400 Subject: more computationally efficient idnum discovery --- bin/mw | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 8adb0b9..01bf86b 100755 --- a/bin/mw +++ b/bin/mw @@ -227,11 +227,9 @@ getboxes() { if [ -n "${force+x}" ] ; then mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" fi [ "$type" = "pop" ] && mailboxes="INBOX" - getaccounts - usednums="$(grep -o "^macro.* i[0-9]\+ " "$muttrc" | grep -o "[0-9]" | sort -u)" - for x in 1 2 3 4 5 6 7 8 9; do - echo "$usednums" | grep -q "$x" || - { export idnum="$x"; break ;} + for x in $(sed -n "/^macro.* i[0-9] / s/\(^macro.* i\| .*\)//gp " $muttrc | sort -u; echo 0); do + idnum=$((idnum + 1)) + [ $idnum -eq $x ] || break done toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`" IFS=' -- cgit v1.2.3 From bd0075898ae441bb5e59f83d8b34df68b55aafb3 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 23 Sep 2021 22:18:54 -0400 Subject: hardcode mailbox names. don't remake shortcuts. --- Makefile | 4 ++-- bin/mailsync | 2 +- bin/mw | 34 +++++++--------------------------- share/mutt-wizard.muttrc | 23 +++++++++++++++++++++++ share/switch.muttrc | 10 ++++++++++ share/unbind.muttrc | 37 ------------------------------------- 6 files changed, 43 insertions(+), 67 deletions(-) create mode 100644 share/switch.muttrc delete mode 100644 share/unbind.muttrc (limited to 'bin/mw') diff --git a/Makefile b/Makefile index 64036d0..03e2df1 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ install: chmod 755 $(DESTDIR)$(PREFIX)/bin/mw $(DESTDIR)$(PREFIX)/bin/mailsync $(DESTDIR)$(PREFIX)/bin/openfile mkdir -p $(DESTDIR)$(PREFIX)/share/mutt-wizard chmod 755 $(DESTDIR)$(PREFIX)/share/mutt-wizard - cp -f share/mailcap share/domains.csv share/mutt-wizard.muttrc share/unbind.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard - chmod 644 $(DESTDIR)$(PREFIX)/share/mutt-wizard/mailcap $(DESTDIR)$(PREFIX)/share/mutt-wizard/domains.csv $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard/unbind.muttrc + cp -f share/mailcap share/domains.csv share/mutt-wizard.muttrc share/switch.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard + chmod 644 $(DESTDIR)$(PREFIX)/share/mutt-wizard/mailcap $(DESTDIR)$(PREFIX)/share/mutt-wizard/domains.csv $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard/switch.muttrc mkdir -p $(DESTDIR)$(MANPREFIX)/man1 cp -f mw.1 $(DESTDIR)$(MANPREFIX)/man1/mw.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/mw.1 diff --git a/bin/mailsync b/bin/mailsync index 9490458..36f963b 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -36,7 +36,7 @@ case "$(uname)" in ;; *) case "$(readlink -f /sbin/init)" in - *systemd*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;; + *systemd*|*openrc*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;; esac # remember if a display server is running since `ps` doesn't always contain a display pgrepoutput="$(pgrep -a X\(org\|wayland\))" diff --git a/bin/mw b/bin/mw index 01bf86b..16df7d3 100755 --- a/bin/mw +++ b/bin/mw @@ -101,7 +101,11 @@ set header_cache = $cachedir/$fulladdr/headers set message_cachedir = $cachedir/$fulladdr/bodies set mbox_type = Maildir set hostname = \"$hostname\" -source $muttshare/unbind.muttrc +source $muttshare/switch.muttrc +set spoolfile = "+INBOX" +set postponed = "+Drafts" +set trash = "+Trash" +set record = "+Sent" $extra $synccmd " > "$accdir/$fulladdr.muttrc" @@ -135,7 +139,6 @@ set ssl_force_tls = yes" esac prepmsmtp prepmutt - prepnotmuch # Create a notmuch config file if not present already. } @@ -211,14 +214,6 @@ createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$fulladdr" getpass() { while : ; do pass rm -f "$fulladdr" >/dev/null 2>&1 pass insert -f "$fulladdr" && break; done ;} -formatShortcut() { toappend="$toappend -macro index,pager g$1 \"=$3\" \"go to $2\" -macro index,pager M$1 \";=$3\" \"move mail to $2\" -macro index,pager C$1 \";=$3\" \"copy mail to $2\"" ;} - -setBox() { toappend="$toappend -set $1 = \"+$2\"" ;} - getboxes() { if [ -n "${force+x}" ] ; then mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" else @@ -232,20 +227,6 @@ getboxes() { if [ -n "${force+x}" ] ; then [ $idnum -eq $x ] || break done toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`" - IFS=' -' - for x in $mailboxes; do - case "$x" in - *[Ss][Ee][Nn][Tt]*) setBox record "$x"; formatShortcut s sent "$x" ;; - *[Dd][Rr][Aa][Ff][Tt][Ss]*) setBox postponed "$x"; formatShortcut d drafts "$x" ;; - *[Tt][Rr][Aa][Ss][Hh]*) formatShortcut t trash "$x"; setBox trash "$x" ;; - *[Jj][Uu][Nn][Kk]*) formatShortcut j junk "$x" ;; - *[Aa][Rr][Cc][Hh][Ii][Vv][Ee]*) formatShortcut a archive "$x" ;; - *[Ss][Pp][Aa][Mm]*) formatShortcut S spam "$x" ;; - *[Ii][Nn][Bb][Oo][Xx]) formatShortcut i inbox "$x"; setBox spoolfile "$x" inbox="$x" ;; - esac - done - unset IFS } finalize() { echo "$toappend" >> "$accdir/$fulladdr.muttrc" @@ -257,7 +238,7 @@ finalize() { echo "$toappend" >> "$accdir/$fulladdr.muttrc" prepnotmuch() { \ [ -z "$NOTMUCH_CONFIG" ] && NOTMUCH_CONFIG="$HOME/.notmuch-config" [ -f "$NOTMUCH_CONFIG" ] && return 0 - nmbasic="[database] + echo "[database] path=$maildir [user] name=$realname @@ -270,8 +251,7 @@ exclude_tags=deleted;spam; [maildir] synchronize_flags=true [crypto] -gpg_path=$GPG" - echo "$nmbasic" > "$NOTMUCH_CONFIG" ;} +gpg_path=$GPG" > "$NOTMUCH_CONFIG" ;} togglecron() { cron="$(mktemp)" crontab -l > "$cron" diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc index 2cb7c8e..a12a77e 100644 --- a/share/mutt-wizard.muttrc +++ b/share/mutt-wizard.muttrc @@ -27,11 +27,15 @@ auto_view text/html # automatically show html (mailcap uses lynx) auto_view application/pgp-encrypted #set display_filter = "tac | sed '/\\\[-- Autoview/,+1d' | tac" # Suppress autoview messages. alternative_order text/plain text/enriched text/html + bind index,pager i noop bind index,pager g noop bind index \Cf noop +bind index,pager M noop +bind index,pager C noop # General rebindings +bind index gg first-entry bind index j next-entry bind index k previous-entry bind attach view-mailcap @@ -65,6 +69,25 @@ bind pager \031 previous-line # Mouse wheel bind pager \005 next-line # Mouse wheel bind editor complete-query +macro index,pager gi "=INBOX" "go to inbox" +macro index,pager Mi ";=INBOX" "move mail to inbox" +macro index,pager Ci ";=INBOX" "copy mail to inbox" +macro index,pager gd "=Drafts" "go to drafts" +macro index,pager Md ";=Drafts" "move mail to drafts" +macro index,pager Cd ";=Drafts" "copy mail to drafts" +macro index,pager gj "=Junk" "go to junk" +macro index,pager Mj ";=Junk" "move mail to junk" +macro index,pager Cj ";=Junk" "copy mail to junk" +macro index,pager gt "=Trash" "go to trash" +macro index,pager Mt ";=Trash" "move mail to trash" +macro index,pager Ct ";=Trash" "copy mail to trash" +macro index,pager gs "=Sent" "go to sent" +macro index,pager Ms ";=Sent" "move mail to sent" +macro index,pager Cs ";=Sent" "copy mail to sent" +macro index,pager ga "=Archive" "go to archive" +macro index,pager Ma ";=Archive" "move mail to archive" +macro index,pager Ca ";=Archive" "copy mail to archive" + #set crypt_autosign = yes #set crypt_opportunistic_encrypt = yes #set pgp_self_encrypt = yes diff --git a/share/switch.muttrc b/share/switch.muttrc new file mode 100644 index 0000000..c808c99 --- /dev/null +++ b/share/switch.muttrc @@ -0,0 +1,10 @@ +# vim: filetype=neomuttrc + +# This is an embarrassing and hacky file that unbinds a bunch of binds between +# switching accounts. It is called each time an account is changed. + +unset hostname +unmy_hdr Organization +unmailboxes * +unalternates * +unset signature diff --git a/share/unbind.muttrc b/share/unbind.muttrc deleted file mode 100644 index 330d823..0000000 --- a/share/unbind.muttrc +++ /dev/null @@ -1,37 +0,0 @@ -# vim: filetype=neomuttrc - -# This is an embarrassing and hacky file that unbinds a bunch of binds between -# switching accounts. It is called each time an account is changed. - -bind index,pager gi noop -bind index,pager gs noop -bind index,pager gd noop -bind index,pager ga noop -bind index,pager gS noop -bind index,pager gj noop -bind index,pager gt noop -bind index,pager Mi noop -bind index,pager Ms noop -bind index,pager Md noop -bind index,pager Ma noop -bind index,pager MS noop -bind index,pager Mj noop -bind index,pager Mt noop -bind index,pager Ci noop -bind index,pager Cs noop -bind index,pager Cd noop -bind index,pager Ca noop -bind index,pager CS noop -bind index,pager Cj noop -bind index,pager Ct noop -bind index,pager gg noop -bind index,pager g noop -bind index,pager M noop -bind index,pager C noop -unset hostname -unmy_hdr Organization -unmailboxes * -unalternates * -unset signature - -bind index gg first-entry -- cgit v1.2.3 From 418565eb94b8d95bb790357afbcf2784511573b5 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 5 Oct 2021 12:17:25 -0400 Subject: minor tweaks --- bin/mailsync | 2 +- bin/mw | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'bin/mw') diff --git a/bin/mailsync b/bin/mailsync index 36f963b..ca7411d 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -43,7 +43,7 @@ case "$(uname)" in displays="$(echo "$pgrepoutput" | grep -wo "[0-9]*:[0-9]\+" | sort -u)" notify() { [ -n "$pgrepoutput" ] && for x in ${displays:-0:}; do export DISPLAY=$x - notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account." + notify-send --app-name="mutt-wizard" "New mail!" "📬 $2 new mail(s) in \`$1\` account." done ;} ;; esac diff --git a/bin/mw b/bin/mw index 16df7d3..d39b0a6 100755 --- a/bin/mw +++ b/bin/mw @@ -198,7 +198,7 @@ askinfo() { \ read -r smtp [ "$sport" = 587 ] && tlsline="# tls_starttls" [ -z "$realname" ] && realname="${fulladdr%%@*}" - hostname="$(echo "$fulladdr" | cut -d @ -f 2)" + hostname="${fulladdr#*@}" login="${login:-$fulladdr}" if [ -n "${password+x}" ]; then createpass @@ -222,9 +222,9 @@ getboxes() { if [ -n "${force+x}" ] ; then mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" fi [ "$type" = "pop" ] && mailboxes="INBOX" - for x in $(sed -n "/^macro.* i[0-9] / s/\(^macro.* i\| .*\)//gp " $muttrc | sort -u; echo 0); do + for x in $(sed -n "/^macro.* i[0-9] / s/\(^macro.* i\| .*\)//gp " "$muttrc" | sort -u; echo 0); do idnum=$((idnum + 1)) - [ $idnum -eq $x ] || break + [ "$idnum" -eq "$x" ] || break done toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`" } @@ -335,7 +335,7 @@ while getopts "fpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in smtp="127.0.0.1" sport="1025" auth="login" - tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | awk '/SHA256:/ {print $2}')" + tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | sed -n '/SHA256:/ s/^\s*SHA256:\s*// p')" setact add || exit 1 ;; *) mwinfo; exit 1 ;; -- cgit v1.2.3 From 85c5d01dcd09058094a8a180c38751e88416b1f4 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Oct 2021 22:51:30 -0400 Subject: mw -r to reorder account numbers --- README.md | 1 + bin/mw | 24 +++++++++++++++++++++++- mw.1 | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/README.md b/README.md index a19170b..372aa02 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ The mutt-wizard runs via the command `mw`. Once setup is complete, you'll use - `mw -D your@email.com` -- delete account settings without confirmation - `mw -t 30` -- toggle automatic mailsync to every 30 minutes - `mw -T` -- toggle mailsync without specifying minutes (default is 10) +- `mw -r` -- reorder account shortcut numbers - `pass edit mw-your@email.com` -- revise an account's password ### Options usable when adding an account diff --git a/bin/mw b/bin/mw index d39b0a6..5205a13 100755 --- a/bin/mw +++ b/bin/mw @@ -285,6 +285,7 @@ Main actions: -Y Sync mail for all accounts -t number Toggle automatic mailsync every minutes -T Toggle automatic mailsync + -r Reorder account numbers Options allowed with -a: -u Account login name if not full address @@ -307,8 +308,28 @@ To change an account's password, run \`pass edit your@email.com\`. EOF } -while getopts "fpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in +reorder(){ + tempfile="$(mktemp -u)" + trap 'rm -f $tempfile' HUP INT QUIT TERM PWR EXIT + echo "# Carefully reorder these accounts with the desired numbers." > "$tempfile" + sed -n " + / i[0-9] / s?\(.* i\|' "$tempfile" + ${EDITOR:-vim} "$tempfile" || exit 1 + default="$(sort -n "$tempfile" | head -n 1)" + default="${default#* }" + sed -ibu "/.* i[0-9] .*.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu + awk -v a="$accdir" -v d="$default" ' BEGIN { print "source "a"/"d".muttrc" } + { + print "macro index,pager i"$1" '\''source "a"/"$2".muttrc!;'\'' \"switch to "$2"\"" + } + ' "$tempfile" >> "$muttrc" + +} + +while getopts "rfpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in l) setact list || exit 1 ;; + r) setact reorder || exit 1 ;; d) setact delete || exit 1 ;; D) setact delete || exit 1 ; fulladdr="$OPTARG" ;; y) setact sync || exit 1 ; fulladdr="$OPTARG" ;; @@ -347,5 +368,6 @@ case "$action" in delete) delete ;; sync) mailsync $fulladdr ;; toggle) togglecron ;; + reorder) reorder ;; *) mwinfo; exit 1 ;; esac diff --git a/mw.1 b/mw.1 index a8c5c8e..4bdb383 100644 --- a/mw.1 +++ b/mw.1 @@ -41,6 +41,9 @@ toggle a cronjob that syncs your mail every 15 minutes (or any other number unde .TP .B -T toggle a cronjob without specifying minutes between sync +.TP +.B -r +reorder account shortcut numbers .SH OPTIONS FOR ADDING ACCOUNTS These can be specified on the command line, otherwise, you will be prompted for what is necessary. mutt-wizard knows the IMAP/SMTP server information for most email providers, so specifying them is usually redundant. .TP -- cgit v1.2.3 From 256c091196c6f7713f875e2a327f2c3755d5c45b Mon Sep 17 00:00:00 2001 From: Jberczel Date: Mon, 1 Nov 2021 11:52:59 -0400 Subject: Cleanup reorder account numbers action Refactors commit 85c5d01 * Keep the comment(s) when reordering account numbers in temp file. Users may accidently reorder rows or rename accounts rather than update order number. * Remove original default config from muttrc. Currently, script only removes the macro shortcuts .If you run reorder action multiple times, you'll end up sourcing multiple "default" config files. --- bin/mw | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 5205a13..bcca18d 100755 --- a/bin/mw +++ b/bin/mw @@ -308,23 +308,27 @@ To change an account's password, run \`pass edit your@email.com\`. EOF } -reorder(){ +reorder() { tempfile="$(mktemp -u)" trap 'rm -f $tempfile' HUP INT QUIT TERM PWR EXIT - echo "# Carefully reorder these accounts with the desired numbers." > "$tempfile" + echo "# Carefully reorder these accounts with the desired numbers in the first column. +# DO NOT reorder rows or rename the accounts in the second column." > "$tempfile" sed -n " / i[0-9] / s?\(.* i\|' "$tempfile" + " "$muttrc" >> "$tempfile" ${EDITOR:-vim} "$tempfile" || exit 1 + sed -i -e 's/#.*//' -e '/^$/d' "$tempfile" default="$(sort -n "$tempfile" | head -n 1)" default="${default#* }" - sed -ibu "/.* i[0-9] .*.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu + sed -ibu " + /.* i[0-9] .*.muttrc/d + /^source.*accounts.*.muttrc/d + " "$muttrc" 2>/dev/null; rm -f "$muttrc"bu awk -v a="$accdir" -v d="$default" ' BEGIN { print "source "a"/"d".muttrc" } { print "macro index,pager i"$1" '\''source "a"/"$2".muttrc!;'\'' \"switch to "$2"\"" } ' "$tempfile" >> "$muttrc" - } while getopts "rfpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in -- cgit v1.2.3 From 29f264db233764a6963bce761b444091b603e114 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 1 Nov 2021 14:14:45 -0400 Subject: Revert "allow dynamically loading available mailboxes" This reverts commit 2cb2fa03452cb99537a1751961574a0b6d3253e0. --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 5205a13..d3129e7 100755 --- a/bin/mw +++ b/bin/mw @@ -226,7 +226,7 @@ getboxes() { if [ -n "${force+x}" ] ; then idnum=$((idnum + 1)) [ "$idnum" -eq "$x" ] || break done - toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`" + toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" } finalize() { echo "$toappend" >> "$accdir/$fulladdr.muttrc" -- cgit v1.2.3 From 37c91057f78542e8970cf7698c0c1588153c30f2 Mon Sep 17 00:00:00 2001 From: Aisha Tammy Date: Fri, 31 Dec 2021 22:55:01 +0000 Subject: add GPG WKS publishing functionality Signed-off-by: Aisha Tammy --- bin/mw | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index d3129e7..fee8974 100755 --- a/bin/mw +++ b/bin/mw @@ -108,6 +108,8 @@ set trash = "+Trash" set record = "+Sent" $extra $synccmd +macro index \eg \"unset wait_keygpg --list-secret-keys; printf 'Enter email ID of user to publish: '; read eID; printf 'Enter fingerprint of GPG key to publish: '; read eFGPT; /usr/local/libexec/gpg-wks-client --create \\\$eFGPT \\\$eID | msmtp --read-envelope-from --read-recipients -a $fulladdr\" \"publish GPG key to WKS provider\" +macro index \eh \"/usr/local/libexec/gpg-wks-client --receive | msmtp --read-envelope-from --read-recipients -a $fulladdr\" \"confirm GPG publication\" " > "$accdir/$fulladdr.muttrc" [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" -- cgit v1.2.3 From a82a86c310bbe2c3a71ff4da3b9ed635fed4e06d Mon Sep 17 00:00:00 2001 From: Aisha Tammy Date: Mon, 10 Jan 2022 20:06:52 +0000 Subject: change path of command to use prefix Signed-off-by: Aisha Tammy --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index fee8974..d2a67d7 100755 --- a/bin/mw +++ b/bin/mw @@ -108,8 +108,8 @@ set trash = "+Trash" set record = "+Sent" $extra $synccmd -macro index \eg \"unset wait_keygpg --list-secret-keys; printf 'Enter email ID of user to publish: '; read eID; printf 'Enter fingerprint of GPG key to publish: '; read eFGPT; /usr/local/libexec/gpg-wks-client --create \\\$eFGPT \\\$eID | msmtp --read-envelope-from --read-recipients -a $fulladdr\" \"publish GPG key to WKS provider\" -macro index \eh \"/usr/local/libexec/gpg-wks-client --receive | msmtp --read-envelope-from --read-recipients -a $fulladdr\" \"confirm GPG publication\" +macro index \eg \"unset wait_keygpg --list-secret-keys; printf 'Enter email ID of user to publish: '; read eID; printf 'Enter fingerprint of GPG key to publish: '; read eFGPT; $prefix/libexec/gpg-wks-client --create \\\$eFGPT \\\$eID | msmtp --read-envelope-from --read-recipients -a $fulladdr\" \"publish GPG key to WKS provider\" +macro index \eh \"$prefix/libexec/gpg-wks-client --receive | msmtp --read-envelope-from --read-recipients -a $fulladdr\" \"confirm GPG publication\" " > "$accdir/$fulladdr.muttrc" [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" -- cgit v1.2.3 From 72fcb51e2434afe4e672019c5fce08d7fdfa8b86 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 14 Jun 2022 07:45:16 -0600 Subject: remove harmless sed error msg if no muttrc --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index 04361fc..d8d4d73 100755 --- a/bin/mw +++ b/bin/mw @@ -224,7 +224,7 @@ getboxes() { if [ -n "${force+x}" ] ; then mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" fi [ "$type" = "pop" ] && mailboxes="INBOX" - for x in $(sed -n "/^macro.* i[0-9] / s/\(^macro.* i\| .*\)//gp " "$muttrc" | sort -u; echo 0); do + for x in $(sed -n "/^macro.* i[0-9] / s/\(^macro.* i\| .*\)//gp " "$muttrc" 2>/dev/null | sort -u; echo 0); do idnum=$((idnum + 1)) [ "$idnum" -eq "$x" ] || break done -- cgit v1.2.3 From 367c10ec3f16c3c11e1a5de980bc95dd4fa6bf79 Mon Sep 17 00:00:00 2001 From: jw Date: Fri, 1 Jul 2022 00:12:04 +0200 Subject: Silence mailsync, so cron doesn't spam e-mails on every update --- bin/mailsync | 7 +++---- bin/mw | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'bin/mw') diff --git a/bin/mailsync b/bin/mailsync index 2f32c14..6aba835 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -70,14 +70,13 @@ syncandnotify() { } # Sync accounts passed as argument or all. -if [ "$#" -eq "0" ]; then - accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" -else +if [ "$#" -gt "0" ]; then for arg in "$@"; do [ "${arg%${arg#?}}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1 done accounts=$* fi +[[ ! $accounts ]] && accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" # Parallelize multiple accounts for account in $accounts; do @@ -86,7 +85,7 @@ done wait -notmuch new 2>/dev/null +notmuch new --quiet #Create a touch file that indicates the time of the last run of mailsync touch "$lastrun" diff --git a/bin/mw b/bin/mw index d8d4d73..8a89a17 100755 --- a/bin/mw +++ b/bin/mw @@ -262,7 +262,7 @@ togglecron() { cron="$(mktemp)" sed -ibu /mailsync/d "$cron"; rm -f "$cron"bu else echo "Adding automatic mailsync every ${cronmin:-10} minutes..." - echo "*/${cronmin-10} * * * * $prefix/bin/mailsync" >> "$cron" + echo "*/${cronmin:-10} * * * * $prefix/bin/mailsync -q" >> "$cron" fi && crontab "$cron"; rm -f "$cron" ;} -- cgit v1.2.3 From ef5bac2b55e3bd665d103eff4ea435ecaa9db22c Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 1 Jul 2022 09:38:07 -0400 Subject: remove Protonmail support. POP server now -p --- README.md | 14 ++------------ bin/mw | 17 +++-------------- mw.1 | 8 +------- share/domains.csv | 3 --- 4 files changed, 6 insertions(+), 36 deletions(-) (limited to 'bin/mw') diff --git a/README.md b/README.md index b634fc7..90243b6 100644 --- a/README.md +++ b/README.md @@ -99,11 +99,10 @@ The mutt-wizard runs via the command `mw`. Once setup is complete, you'll use #### General Settings -- `-p` -- Add a Protonmail account. - `-f` -- Assume mailbox names and force account configuration without connecting online at all. - `-o` -- Configure mutt for an account, but do not keep mail offline. -- `-P` -- Use POP protocol instead of IMAP (requires `mpop` installed). +- `-p` -- Use POP protocol instead of IMAP (requires `mpop` installed). ## Neomutt user interface @@ -168,7 +167,7 @@ To give you an example of the interface, here's an idea: errors generally. - Addition of a manual `man mw` - Now handles POP protocol via `mpop` for those who prefer it (add an account - with the `-P` option). POP configs are still generated automatically. + with the `-p` option). POP configs are still generated automatically. ## Help the Project! @@ -205,15 +204,6 @@ See Luke's website [here](https://lukesmith.xyz). Email him at applications requires turning off two-factor authentication and this will circumvent that. You might also need to manually "Enable IMAP" in the settings. -- Protonmail accounts require a "Protonmail Bridge" to access - PM's IMAP and SMTP servers. Configure that before running mutt-wizard. Note - that when mutt-wizard asks for a password, you should put in your - [bridge password](https://protonmail.com/bridge/thunderbird#3), not your - account password. -- Protonmail bridge is prone to timing out. Watch out for this while adding an - account. If the bridge times out, try again. It might help to - [increase the timeout](https://protonmail.com/support/knowledge-base/thunderbird-connection-server-timed-error/) - in your `mbsyncrc`. - If you have a university email or enterprise-hosted email for work, there might be other hurdles or two-factor authentication you have to jump through. Some, for example, will want you to create a separate IMAP password, etc. diff --git a/bin/mw b/bin/mw index d8d4d73..f0b46e2 100755 --- a/bin/mw +++ b/bin/mw @@ -297,8 +297,7 @@ Options allowed with -a: -s SMTP server address -S SMTP server port -x Password for account (recommended to be in double quotes) - -p Install for a Protonmail account. - -P Add for a POP server instead of IMAP. + -p Add for a POP server instead of IMAP. -X Delete an account's local email too when deleting. -o Configure address, but keep mail online. -f Assume typical English mailboxes without attempting log-on. @@ -333,7 +332,7 @@ reorder() { ' "$tempfile" >> "$muttrc" } -while getopts "rfpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in +while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in l) setact list || exit 1 ;; r) setact reorder || exit 1 ;; d) setact delete || exit 1 ;; @@ -349,22 +348,12 @@ while getopts "rfpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in n) setact add || exit 1 ; realname="$OPTARG" ;; m) setact add || exit 1 ; maxmes="$OPTARG" ;; o) setact add || exit 1 ; type="online" ;; - P) setact add || exit 1 ; type="pop"; protocol="pop3s" ; iport="${iport:-995}" ;; + p) setact add || exit 1 ; type="pop"; protocol="pop3s" ; iport="${iport:-995}" ;; f) setact add || exit 1 ; force=True ;; x) setact add || exit 1 ; password="$OPTARG" ;; X) setact delete || exit 1 ; purge=True ;; t) setact toggle || exit 1 ; cronmin="$OPTARG" ;; T) setact toggle || exit 1 ;; - p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." - protocol="imap" - imap="127.0.0.1" - iport="1143" - smtp="127.0.0.1" - sport="1025" - auth="login" - tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | sed -n '/SHA256:/ s/^\s*SHA256:\s*// p')" - setact add || exit 1 - ;; *) mwinfo; exit 1 ;; esac done diff --git a/mw.1 b/mw.1 index 2172f80..c3cbd07 100644 --- a/mw.1 +++ b/mw.1 @@ -80,9 +80,6 @@ Create settings for an account to be used online only without mail syncing abili .B -f connection will still be attempted in setup to discover mailboxes. .TP -.B -p -Add a Protonmail account. Protonmail Bridge must be installed and set up. -.TP .B -X When removing an email profile with either .I -d @@ -90,7 +87,7 @@ or .I -D, also delete the local mail (will not delete the mail on the server). .TP -.B -P +.B -p Use POP protocol instead of IMAP. Requires .I mpop to download mail after configuration. Server details can still be given with the @@ -155,9 +152,6 @@ on mutt-wizard's Github or Gitlab .B Gmail accounts Google will require you to allow "less-secure" (third party) applications or remove two-factor authentication in order to access their IMAP servers to download your mail. If you use Gmail, be sure to handle this before running mutt-wizard . .TP -.B Protonmail accounts -Protonmail users must use the Protonmail Bridge to access their IMAP and SMTP servers. This too should be configured before running mutt-wizard. -.TP .B Enterprise and university accounts Many universities and businesses might host their domain's email via Google or another service. This often requires a special IMAP/SMTP-specific password that you must generate and use. Again, mutt-wizard can handle these systems, but only once they've been set up. .TP diff --git a/share/domains.csv b/share/domains.csv index be0086e..77a20af 100644 --- a/share/domains.csv +++ b/share/domains.csv @@ -217,7 +217,6 @@ parabolas.xyz,mail.parabolas.xyz,993,mail.parabolas.xyz,587 paranoici.org,mail.autistici.org,993,smtp.autistici.org,465 paranoid.email,imap.paranoid.email,993,smtp.paranoid.email,25 paranoid.network,imap.nixnet.email,143,smtp.nixnet.email,587 -pm.me,127.0.0.1,1143,127.0.0.1,1025 poczta.fm,poczta.interia.pl,993,poczta.interia.pl,465 poczta.onet.pl,imap.poczta.onet.pl,993,smtp.poczta.onet.pl,465 polimi.it,outlook.office365.com,993,smtp.office365.com,587 @@ -227,8 +226,6 @@ posteo.*,posteo.de,993,posteo.de,587 privacy.xyz,imap.nixnet.email,143,smtp.nixnet.email,587 privacyrequired.com,mail.autistici.org,993,smtp.autistici.org,465 prokonto.pl,poczta.o2.pl,993,poczta.o2.pl,465 -protonmail.ch,127.0.0.1,1143,127.0.0.1,1025 -protonmail.com,127.0.0.1,1143,127.0.0.1,1025 purelymail.com,imap.purelymail.com,993,smtp.purelymail.com,465 pwned.life,imap.nixnet.email,143,smtp.nixnet.email,587 qq.com,imap.qq.com,993,smtp.qq.com,587 -- cgit v1.2.3 From 315069b5a27a7965dfa9efb5778ddaa6421e02eb Mon Sep 17 00:00:00 2001 From: Lokesh Mohanty Date: Sat, 2 Jul 2022 21:46:54 +0530 Subject: pass: add feature to optionally add a prefix --- bin/mw | 29 ++++++++++++++++------------- mw.1 | 2 ++ 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index c71d662..cd5235c 100755 --- a/bin/mw +++ b/bin/mw @@ -43,7 +43,7 @@ host $smtp port ${sport:-465} from $fulladdr user $login -passwordeval \"pass $fulladdr\" +passwordeval \"pass $passprefix$fulladdr\" auth ${auth:-on} tls on tls_trust_file $sslcert @@ -58,7 +58,7 @@ IMAPStore $fulladdr-remote Host $imap Port ${iport:-993} User $login -PassCmd \"pass $fulladdr\" +PassCmd \"pass $passprefix$fulladdr\" AuthMechs LOGIN SSLType ${imapssl:-IMAPS} CertificateFile $sslcert @@ -87,7 +87,7 @@ tls on user $login host $imap delivery maildir ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-INBOX} -passwordeval pass $fulladdr +passwordeval pass $passprefix$fulladdr " >> "$mpoprc" ;} prepmutt() { echo "# vim: filetype=neomuttrc @@ -128,7 +128,7 @@ getprofiles() { \ case "$type" in online) folder="imaps://$login@$imap:${iport:-993}" extra="set imap_user = \"$login\" -set imap_pass = \"\`pass $fulladdr\`\" +set imap_pass = \"\`pass $passprefix$fulladdr\`\" set ssl_starttls = yes set ssl_force_tls = yes" ;; @@ -176,7 +176,7 @@ delete() { if [ -z "${fulladdr+x}" ]; then sed -ibu "/\([0-9]-\)\?$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu - pass rm -f "$fulladdr" >/dev/null 2>&1 + pass rm -f "$passprefix$fulladdr" >/dev/null 2>&1 [ -n "${purge+x}" ] && rm -rf "${maildir:?}/${fulladdr:?}" for file in "$msmtprc" "$mbsyncrc" "$mpoprc"; do @@ -200,6 +200,7 @@ askinfo() { \ read -r smtp [ "$sport" = 587 ] && tlsline="# tls_starttls" [ -z "$realname" ] && realname="${fulladdr%%@*}" + [ -z "$passprefix" ] && passprefix="" hostname="${fulladdr#*@}" login="${login:-$fulladdr}" if [ -n "${password+x}" ]; then @@ -209,17 +210,17 @@ askinfo() { \ fi } -createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$fulladdr" - "$GPG" -qe $(printf -- " -r %s" $(cat "$PASSWORD_STORE_DIR/.gpg-id")) "$PASSWORD_STORE_DIR/$fulladdr" - rm -f "$PASSWORD_STORE_DIR/$fulladdr" ;} +createpass() { echo "$password" > "$PASSWORD_STORE_DIR/$passprefix$fulladdr" + "$GPG" -qe $(printf -- " -r %s" $(cat "$PASSWORD_STORE_DIR/.gpg-id")) "$PASSWORD_STORE_DIR/$passprefix$fulladdr" + rm -f "$PASSWORD_STORE_DIR/$passprefix$fulladdr" ;} -getpass() { while : ; do pass rm -f "$fulladdr" >/dev/null 2>&1 - pass insert -f "$fulladdr" && break; done ;} +getpass() { while : ; do pass rm -f "$passprefix$fulladdr" >/dev/null 2>&1 + pass insert -f "$passprefix$fulladdr" && break; done ;} getboxes() { if [ -n "${force+x}" ] ; then mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" else - info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" + info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$passprefix$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && echo "Log-on not successful." && return 1 mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')" fi @@ -297,6 +298,7 @@ Options allowed with -a: -s SMTP server address -S SMTP server port -x Password for account (recommended to be in double quotes) + -P Pass Prefix (prefix of the file where password is stored) -p Add for a POP server instead of IMAP. -X Delete an account's local email too when deleting. -o Configure address, but keep mail online. @@ -305,7 +307,7 @@ Options allowed with -a: NOTE: Once at least one account is added, you can run \`mbsync -a\` to begin downloading mail. -To change an account's password, run \`pass edit your@email.com\`. +To change an account's password, run \`pass edit '$passprefix'your@email.com\`. EOF } @@ -332,7 +334,7 @@ reorder() { ' "$tempfile" >> "$muttrc" } -while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in +while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:P:x:m:t:" o; do case "${o}" in l) setact list || exit 1 ;; r) setact reorder || exit 1 ;; d) setact delete || exit 1 ;; @@ -346,6 +348,7 @@ while getopts "rfpXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in S) setact add || exit 1 ; sport="$OPTARG" ;; u) setact add || exit 1 ; login="$OPTARG" ;; n) setact add || exit 1 ; realname="$OPTARG" ;; + P) setact add || exit 1 ; passprefix="$OPTARG" ;; m) setact add || exit 1 ; maxmes="$OPTARG" ;; o) setact add || exit 1 ; type="online" ;; p) setact add || exit 1 ; type="pop"; protocol="pop3s" ; iport="${iport:-995}" ;; diff --git a/mw.1 b/mw.1 index c3cbd07..e4755ba 100644 --- a/mw.1 +++ b/mw.1 @@ -70,6 +70,8 @@ SMTP server port (assumed to be 465 if not specified) .TP .B -x Account password. You will be prompted for the password interactively if this option is not given. +.B -P +Pass Prefix. The password will be stored using pass at .SH OTHER OPTIONS .TP .B -f -- cgit v1.2.3 From 0b9135142a22dfc696628d620407e913cc58f778 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 4 Jul 2022 23:59:24 -0400 Subject: move msmtp cache and reorder prep --- bin/mw | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index c71d662..739d2bb 100755 --- a/bin/mw +++ b/bin/mw @@ -7,14 +7,13 @@ cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard" muttrc="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/muttrc" accdir="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/accounts" msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" -msmtplog="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/msmtp.log" +msmtplog="${XDG_CACHE_HOME:-$HOME/.cache}/msmtp/msmtp.log" mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" mpoprc="${XDG_CONFIG_HOME:-$HOME/.config}/mpop/config" alias mbsync='mbsync -c "$mbsyncrc"' # On Ubuntu/Debian, a link is needed since they use an older version. if command -V apt-get >/dev/null 2>&1; then - ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null master="Master" slave="Slave" fi @@ -38,7 +37,9 @@ getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "\S* list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" || exit 1 ;} -prepmsmtp() { echo "account $fulladdr +prepmsmtp() { mkdir -p "${msmtprc%/*}" "${msmtplog%/*}" + ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null + echo "account $fulladdr host $smtp port ${sport:-465} from $fulladdr @@ -90,7 +91,8 @@ delivery maildir ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-IN passwordeval pass $fulladdr " >> "$mpoprc" ;} -prepmutt() { echo "# vim: filetype=neomuttrc +prepmutt() { mkdir -p "${muttrc%/*}" "${accdir%/*}" + echo "# vim: filetype=neomuttrc # muttrc file for account $fulladdr set realname = \"$realname\" set from = \"$fulladdr\" @@ -119,8 +121,6 @@ macro index \eh \"$prefix/libexec/gpg-wks-client --receive | msmtp } getprofiles() { \ - mkdir -p "${muttrc%/*}" "$accdir" "${XDG_CONFIG_HOME:-$HOME/.config}/msmtp" - unset msmtp_header msmtp_profile mutt_profile mbsync_profile case "$iport" in 1143) imapssl=None ;; 143) imapssl=STARTTLS ;; -- cgit v1.2.3 From 36c87c512ed0e5b2fd3e67b79711eaab555de5e3 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 5 Jul 2022 17:37:36 -0400 Subject: removed introduced bug, fix #861 --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/mw') diff --git a/bin/mw b/bin/mw index f444cb7..52c46cc 100755 --- a/bin/mw +++ b/bin/mw @@ -91,7 +91,7 @@ delivery maildir ${XDG_DATA_HOME:-$HOME/.local/share}/mail/$fulladdr/${inbox:-IN passwordeval pass $passprefix$fulladdr " >> "$mpoprc" ;} -prepmutt() { mkdir -p "${muttrc%/*}" "${accdir%/*}" +prepmutt() { mkdir -p "${muttrc%/*}" "$accdir" echo "# vim: filetype=neomuttrc # muttrc file for account $fulladdr set realname = \"$realname\" -- cgit v1.2.3