mutt-wizard

A wizard that autocreates an offline email setup for (neo)mutt with isync/mbsync
Log | Files | Refs | README | LICENSE

commit d951fb64c587bf909fe6e0130a689a94c4055296
parent ce78b37dc21ebe8436e1f0639942847ef56d8f4c
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Tue, 12 Nov 2019 06:17:45 -0500

Merge branch 'master' of github.com:LukeSmithxyz/mutt-wizard

Diffstat:
MMakefile | 1+
MREADME.md | 4++--
Mbin/mailsync | 5+++--
Mbin/mw | 18++++++++++++++++--
Mshare/domains.csv | 14++++++++++----
Mshare/mutt-wizard.muttrc | 4++--
6 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile @@ -30,5 +30,6 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/$$script; \ done rm -rf $(DESTDIR)$(PREFIX)/share/mutt-wizard + rm -f $(DESTDIR)$(MANPREFIX)/man1/mw.1 .PHONY: install uninstall diff --git a/README.md b/README.md @@ -110,9 +110,9 @@ mutt-wizard is free/libre software, licensed under the GPLv3. - 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: - -- For Gmail accounts, remember also to enable third-party ("""less secure""") applications before attempting installation. You might also need to manually "Enable IMAP" in the settings. +- 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. +- Protonmail bridge is prone to timing out. Watch out for this while adding an account. If the bridge times out, try again. - 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. diff --git a/bin/mailsync b/bin/mailsync @@ -2,12 +2,13 @@ # Sync mail and give notification if there is new mail. export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus +DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus +export DBUS_SESSION_BUS_ADDRESS export DISPLAY=:0.0 [ -d "$HOME/.local/share/password-store" ] && export PASSWORD_STORE_DIR="$HOME/.local/share/password-store" # Run only if user logged in (prevent cron errors) -pgrep -u "$USER" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;} +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 ;} diff --git a/bin/mw b/bin/mw @@ -134,8 +134,22 @@ askinfo() { \ 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' && break;; + *) + 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 "^$domain" "$muttshare/domains.csv" 2>/dev/null)" + serverinfo="$(grep "^$search_query" "$muttshare/domains.csv" 2>/dev/null)" 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" @@ -194,7 +208,7 @@ EOF } protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n" - fingerprint="$(msmtp --serverinfo --host=127.0.0.1 --port=1025 --tls --tls-certcheck=off)" || return 1 + 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 } diff --git a/share/domains.csv b/share/domains.csv @@ -60,7 +60,7 @@ counsellor.com,imap.mail.com,993,smtp.mail.com,587 cryptolab.net,mail.autistici.org,993,smtp.autistici.org,465 cumallover.me,mail.cock.li,993,mail.cock.li,587 cyberservices.com,imap.mail.com,993,smtp.mail.com,587 -datentopf.org,mail.datentopf.org,993,mail.datentopf.org,587 +datentopf.org,imap.migadu.com,993,smtp.migadu.com,587 deliveryman.com,imap.mail.com,993,smtp.mail.com,587 dicksinhisan.us,mail.cock.li,993,mail.cock.li,587 dicksinmyan.us,mail.cock.li,993,mail.cock.li,587 @@ -129,7 +129,7 @@ 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,imap-mail.outlook.com,993,smtp-mail.outlook.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 @@ -143,6 +143,7 @@ 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 +humbug.pw,imap.migadu.com,993,smtp.migadu.com,587 hushmail.com,imap.hushmail.com,993,smtp.hushmail.com,465 illinois.edu, imap.gmail.com,993,smtp.gmail.com,465 iname.com,imap.mail.com,993,smtp.mail.com,587 @@ -170,6 +171,7 @@ mail.mcgill.ca,outlook.office365.com,993,smtp.office365.com,587 mail.polimi.it,outlook.office365.com,993,smtp.office365.com,587 mail.ru,imap.mail.ru,993,smtp.mail.ru,465 mailbox.org,imap.mailbox.org,993,smtp.mailbox.org,587 +mailbox.tu-dresden.de,msx.tu-dresden.de,993,msx.tu-dresden.de,587 mailo.com,mail.mailo.com,993,mail.mailo.com,465 memeware.net,mail.cock.li,993,mail.cock.li,587 ml1.net,imap.fastmail.com,993,smtp.fastmail.com,465 @@ -212,18 +214,20 @@ protonmail.ch,127.0.0.1,1143,127.0.0.1,1025 protonmail.com,127.0.0.1,1143,127.0.0.1,1025 rape.lol,mail.cock.li,993,mail.cock.li,587 redchan.it,mail.cock.li,993,mail.cock.li,587 +resch.pw,imap.migadu.com,993,smtp.migadu.com,587 runbox.com,mail.runbox.com,993,mail.runbox.com,587 rwth-aachen.de,mail.rwth-aachen.de,993,mail.rwth-aachen.de,587 sapo.pt,imap.sapo.pt,993,smtp.sapo.pt,587 smail.inf.h-brs.de,imap.inf.h-brs.de,993,smtp.inf.h-brs.de,587 southwales.ac.uk,imap.gmail.com,993,smtp.gmail.com,587 spoko.pl,imap.poczta.onet.pl,993,smtp.poczta.onet.pl,465 -stevens.edu,imap-mail.outlook.com,993,smpt-mail.outlook.com,587 +stevens.edu,imap.outlook.com,993,smtp.outlook.com,587 stronzi.org,mail.autistici.org,993,smtp.autistici.org,465 stud.tu-darmstadt.de,imap.stud.tu-darmstadt.de,993,smtp.tu-darmstadt.de,465 stud.uis.no,outlook.office365.com,993,smtp.office365.com,587 stud.uni-bamberg.de,outlook.office365.com,993,smtp.office365.com,587 student.rmit.edu.au,outlook.office365.com,993,smtp.office365.com,587 +student.tuwien.ac.at,mail.student.tuwien.ac.at,993,mail.student.tuwien.ac.at,587 students.southwales.ac.uk,imap.gmail.com,993,smtp.gmail.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 @@ -238,7 +242,6 @@ tlu.edu,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 tquad.ai,imap.mail.eu-west-1.awsapps.com,993,smtp.mail.eu-west-1.awsapps.com,465 tu-harburg.de,mail.tu-harburg.de,993,mail.tu-harburg.de,587 tuhh.de,mail.tu-harburg.de,993,mail.tu-harburg.de,587 -tuwien.at,mail.student.tuwien.ac.at,993,mail.student.tuwien.ac.at,587 txstate.edu,outlook.office365.com,993,smtp.office365.com,587 ua.pt,outlook.office365.com,993,mail.ua.pt,25 uach.mx,imap.gmail.com,993,smtp.gmail.com,587 @@ -259,6 +262,7 @@ wanadoo.fr,imap.orange.fr,993,smtp.orange.fr,465 wants.dicksinhisan.us,mail.cock.li,993,mail.cock.li,587 wants.dicksinmyan.us,mail.cock.li,993,mail.cock.li,587 web.de,imap.web.de,993,smtp.web.de,587 +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 @@ -272,3 +276,5 @@ 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 zoho.com,imap.zoho.com,993,smtp.zoho.com,465 +polito.it,mail.polito.it,993,mail.polito.it,465 +studio.unibo.it,outlook.office365.com,993,smtp.office365.com,587 diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc @@ -60,9 +60,9 @@ bind pager \031 previous-line # Mouse wheel bind pager \005 next-line # Mouse wheel bind editor <Tab> complete-query -macro index,pager a "|abook --add-email\n" 'add sender to abook' +macro index,pager a "<enter-command>set my_pipe_decode=\$pipe_decode pipe_decode<return><pipe-message>abook --add-email<return><enter-command>set pipe_decode=\$my_pipe_decode; unset my_pipe_decode<return>" "add the sender address to abook" macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read" -macro index O "<shell-escape>mailsync -Va<enter>" "run offlineimap to sync all mail" +macro index O "<shell-escape>mailsync -Va<enter>" "run mbsync to sync all mail" macro index \Cf "<enter-command>unset wait_key<enter><shell-escape>read -p 'Enter a search term to find with notmuch: ' x; echo \$x >~/.cache/mutt_terms<enter><limit>~i \"\`notmuch search --output=messages \$(cat ~/.cache/mutt_terms) | head -n 600 | perl -le '@a=<>;s/\^id:// for@a;$,=\"|\";print@a' | perl -le '@a=<>; chomp@a; s/\\+/\\\\+/ for@a;print@a' \`\"<enter>" "show only messages matching a notmuch pattern" macro index A "<limit>all\n" "show all messages (undo limit)"