Browse Source

merge with upstream

pull/170/head
otlin100 5 years ago
parent
commit
2d2cda5bf6
9 changed files with 89 additions and 36 deletions
  1. +20
    -16
      Makefile
  2. +14
    -4
      README.md
  3. +3
    -0
      bin/mailsync
  4. +30
    -11
      bin/mw
  5. +2
    -1
      bin/openfile
  6. +2
    -0
      mw.1
  7. +18
    -4
      share/domains.csv
  8. +0
    -0
      share/mailcap
  9. +0
    -0
      share/mutt-wizard.muttrc

+ 20
- 16
Makefile View File

@@ -1,30 +1,34 @@
.POSIX:

PREFIX = /usr
OS = $(shell uname -s)
ifeq ($(OS), Darwin)
PREFIX = /usr/local
else
PREFIX = /usr
endif
MANPREFIX = $(PREFIX)/share/man

install:
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f bin/mw $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/mw
cp -f bin/openfile $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/openfile
cp -f bin/muttimage $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/muttimage
cp -f bin/mailsync $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/mailsync
for script in bin/*; do \
cp -f $$script $(DESTDIR)$(PREFIX)/bin/; \
chmod 755 $(DESTDIR)$(PREFIX)/$$script; \
done
mkdir -p $(DESTDIR)$(PREFIX)/share/mutt-wizard
for shared in share/*; do \
cp -f $$shared $(DESTDIR)$(PREFIX)/share/mutt-wizard; \
done
if [ "$(OS)" = "Darwin" ]; then \
sed -iba 's/\/usr\//\/usr\/local\//' $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrc; \
rm $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrcba; \
fi
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
cp -f mailcap $(DESTDIR)$(PREFIX)/share/mutt-wizard
cp -f mutt-wizard.muttrc $(DESTDIR)$(PREFIX)/share/mutt-wizard
cp -f domains.csv $(DESTDIR)$(PREFIX)/share/mutt-wizard
cp -f mw.1 $(DESTDIR)$(MANPREFIX)/man1/mw.1

uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/mw
rm -f $(DESTDIR)$(PREFIX)/bin/mailsync
rm -f $(DESTDIR)$(PREFIX)/bin/openfile
rm -f $(DESTDIR)$(PREFIX)/bin/muttimage
for script in bin/*; do \
rm -f $(DESTDIR)$(PREFIX)/bin/$$script; \
done
rm -rf $(DESTDIR)$(PREFIX)/share/mutt-wizard

.PHONY: install uninstall

+ 14
- 4
README.md View File

@@ -48,6 +48,8 @@ The mutt-wizard is run with the command `mw`. It also installs the `mailsync` co
- `msmtp` - sends the email.
- `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`.

### Optional

- `w3m` - view HTML email and images in neomutt.
@@ -56,6 +58,7 @@ The mutt-wizard is run with the command `mw`. It also installs the `mailsync` co
- `abook` - a terminal-based address book. Pressing tab while typing an address to send mail to will suggest contacts that are in your abook.
- A cron manager - if you want to enable the auto-sync feature.
- `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

@@ -72,8 +75,8 @@ To give you an example of the interface, here's an idea:
- `i#` - Press `i` followed by a number 1-9 to go to a different account. If you add 9 accounts via mutt-wizard, they will each be assigned a number.
- `a` to add address/person to abook and `Tab` while typing address to complete one from book.
- `?` - see all keyboard shortcuts
- `ctrl-j`/`ctrl-k` - move up and down in sidebar, `ctrl-o` opens mailbox
- `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

- `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.
@@ -108,7 +111,14 @@ mutt-wizard is free/libre software, licensed under the GPLv3.

## Watch out for these things:

- For Gmail accounts, remember also to enable third-party ("""less secure""") applications before attempting installation.
- 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.
- Protonmail accounts will require you to set up "Protonmail Bridge" to access PM's IMAP and SMTP servers. Configure that before running mutt-wizard.
- 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.
- If you use an email server whose mailboxes are not in English, mutt-wizard might not be able to guess which is which, so you may have to manually set your Inbox, Sent, Trash, Drafts, etc. in your mutt config file. Do this after running the wizard in `accounts/NAME.muttrc`.
- `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

- Add Mac OS/BSD compatibility
- Out-of-the-box compatibility with Protonmail Bridge
- Option to ignore `domains.csv` (for troubleshooting)
- Option to keep configuration for accounts that failed to connect (maybe)

+ 3
- 0
bin/mailsync View File

@@ -1,6 +1,9 @@
#!/usr/bin/env sh
# Sync mail and give notification if there is new mail.

# Run only if user logged in (prevent cron errors)
pgrep -cu "$USER" >/dev/null || exit

# Checks for internet connection and set notification script.
ping -q -c 1 1.1.1.1 > /dev/null || exit
command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script."


+ 30
- 11
bin/mw View File

@@ -1,24 +1,33 @@
#!/bin/sh
[ ! -f "$HOME/.password-store/.gpg-id" ] && printf "\`pass\` or \`gopass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`(go)pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`gpg --full-gen-key\` first.\\n" && exit
command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2"
! "$GPG" --list-secret-keys $(cat "$HOME/.password-store/.gpg-id") >/dev/null 2>&1 && printf "\`pass\` or \`gopass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`$GPG --full-gen-key\` first.\\n" && exit
! command -v mbsync >/dev/null && printf "\`mbsync\` must be installed to run mutt-wizard.\\n" && exit

pass="pass"
ifinstalled gopass
if [ $? -eq 0 ]; then
pass="gopass"

if [[ "$OSTYPE" == "darwin"* ]]; then
prefix="/usr/local"
else
prefix="/usr"
fi

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
muttshare="/usr/share/mutt-wizard"
muttshare="$prefix/share/mutt-wizard"
mbsyncrc="$HOME/.mbsyncrc"
mwconfig="$muttshare/mutt-wizard.muttrc"
cachedir="$HOME/.cache/mutt-wizard"
muttrc="$muttdir/muttrc"
msmtprc="$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"
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"
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 ;}
@@ -91,7 +100,7 @@ mutt_profile="# vim: filetype=neomuttrc
# muttrc file for account $title
set realname = \"$realname\"
set from = \"$fulladdr\"
set sendmail = \"/usr/bin/msmtp -a $title\"
set sendmail = \"$prefix/bin/msmtp -a $title\"
alias me $realname <$fulladdr>
set folder = \"imaps://$fulladdr@$imap:$iport\"
set imap_user = \"$login\"
@@ -144,7 +153,7 @@ EOF
printf "\\n\033[3;33mCongrats!\033[0m Server info has automatically been found, so you won't have to look anything up!\\n\t\033[1mIMAP server\033[0m: %s\\n\t\033[1mIMAP port\033[0m: %s\\n\t\033[1mSMTP server\033[0m: %s\\n\t\033[1mSMTP port\033[0m: %s\\nThis data will be used by the wizard.\\n" "$imap" "$iport" "$smtp" "$sport"
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.*) 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" ;;
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
fi
printf "Enter the \033[35mfull name\033[0m you want to be identified by on this account.\\n\tReal name: "
@@ -167,8 +176,12 @@ EOF
mkdir -p "$muttdir" "$accdir" "$cachedir/$title/bodies" "$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 "$HOME/.config/msmtp/config" ] && echo "$msmtp_header" > "$HOME/.config/msmtp/config"
echo "$msmtp_profile" >> "$HOME/.config/msmtp/config"
[ ! -f "$msmtprc" ] && echo "$msmtp_header" > "$msmtprc"
echo "$msmtp_profile" >> "$msmtprc"
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
echo "$mutt_profile" > "$accdir/$idnum-$title.muttrc"
echo "$mbsync_profile" >> "$mbsyncrc"
notmuchauto
@@ -178,7 +191,12 @@ EOF
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$title.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\" # mw-autogenerated" >> "$muttrc"
}

getpass() { while : ; do $pass rm -f "mutt-wizard-$title" >/dev/null 2>&1
protonfinger() { printf "Getting Protonmail bridge fingerprint...\\n"
fingerprint="$(msmtp --serverinfo --tls --tls-certcheck=off -a "$title")" || return 1
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 ;}

formatShortcut() { \
@@ -219,6 +237,7 @@ finalize() { \
echo "$boxes" | grep -i junk | head -n 1 | formatShortcut j junk
echo "$boxes" | grep -i archive | head -n 1 | formatShortcut a archive
[ "$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
}

@@ -237,10 +256,10 @@ pick() { printf "Select an accounts to %s:\\n" "$1"
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" "$HOME/.config/msmtp/config"; rm -f "$HOME/.config/msmtp/configbu"
sed -ibu "/account $title/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu
}

choosecron() { ! pgrep -x cron\|crond >/dev/null && echo "No cron manager running. Install/enable one and then select this option again." && return 1
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"
@@ -292,7 +311,7 @@ exclude_tags=deleted;spam;
[maildir]
synchronize_flags=true
[crypto]
gpg_path=gpg"
gpg_path=$GPG"
echo "$nmbasic" > "$NOTMUCH_CONFIG" ;}

case "$1" in


+ 2
- 1
bin/openfile View File

@@ -1,8 +1,9 @@
#!/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"
base=$(basename "$1")
ext="${base##*.}"
file=$(mktemp -u --suffix=".$ext")
rm -f "$file"
cp "$1" "$file"
setsid xdg-open "$file" >/dev/null 2>&1 &
$opener "$file" >/dev/null 2>&1 &

+ 2
- 0
mw.1 View File

@@ -203,6 +203,8 @@ to move mail to the same boxes.
mutt-wizard can configure as many as nine accounts each numbered by the lowest available number when configured. Press
.I i
followed by an account's number to change to that account: i2, i5, etc.
.I ctrl-b
to open a menu to select a url you want to open in you browser.
.TP
.B Sidebar
mutt-wizard enables the sidebar by default which displays your account's boxes with mail tallies.


domains.csv → share/domains.csv View File

@@ -9,6 +9,7 @@ airmail.cc,mail.cock.li,993,mail.cock.li,587
allergist.com,imap.mail.com,993,smtp.mail.com,587
alumni.com,imap.mail.com,993,smtp.mail.com,587
alumnidirector.com,imap.mail.com,993,smtp.mail.com,587
alunos.utfpr.edu.br,imap.gmail.com,993,smtp.gmail.com,587
anche.no,mail.autistici.org,993,smtp.autistici.org,465
angelic.com,imap.mail.com,993,smtp.mail.com,587
aol.com,imap.aol.com,993,smtp.aol.com,465
@@ -37,6 +38,7 @@ cash4u.com,imap.mail.com,993,smtp.mail.com,587
cheerful.com,imap.mail.com,993,smtp.mail.com,587
chef.net,imap.mail.com,993,smtp.mail.com,587
chemist.com,imap.mail.com,993,smtp.mail.com,587
chrissx.ga,chrissx.ga,993,chrissx.ga,25
clerk.com,imap.mail.com,993,smtp.mail.com,587
clubmember.org,imap.mail.com,993,smtp.mail.com,587
cocaine.ninja,mail.cock.li,993,mail.cock.li,587
@@ -62,7 +64,7 @@ disroot.org,disroot.org,993,disroot.org,587
distruzione.org,mail.autistici.org,993,smtp.autistici.org,465
dr.com,imap.mail.com,993,smtp.mail.com,587
duke.edu,outlook.office365.com,993,smtp.office365.com,587
email.arizona.edu,mail.catnet.arizona.edu,993,smtpgate.email.arizona.edu,587
email.arizona.edu,imap.gmail.com,993,smtp.gmail.com,587
email.com,imap.mail.com,993,smtp.mail.com,587
engineer.com,imap.mail.com,993,smtp.mail.com,587
erciyes.edu.tr,posta.erciyes.edu.tr,993,smtp.erciyes.edu.tr,587
@@ -75,6 +77,7 @@ fsmpi.rwth-aachen.de,mail.fsmpi.rwth-aachen.de,993,mail.fsmpi.rwth-aachen.de,465
fsu-jena,exchange.uni-jena.de,993,smtp.uni-jena.de,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
@@ -99,8 +102,9 @@ illinois.edu, imap.gmail.com,993,smtp.gmail.com,465
iname.com,imap.mail.com,993,smtp.mail.com,587
insiberia.net,mail.autistici.org,993,smtp.autistici.org,465
insicuri.net,mail.autistici.org,993,smtp.autistici.org,465
interia.eu,poczta.interia.pl,143,poczta.interia.pl,465
interia.pl,poczta.interia.pl,143,poczta.interia.pl,465
interia.eu,poczta.interia.pl,993,poczta.interia.pl,465
interia.pl,poczta.interia.pl,993,poczta.interia.pl,465
interactio.io,imap.gmail.com,993,smtp.gmail.com,587
inventati.org,mail.autistici.org,993,smtp.autistici.org,465
kipras.org,mail.kipras.org,993,mail.kipras.org,587
krutt.org,mail.autistici.org,993,smtp.autistici.org,465
@@ -125,7 +129,9 @@ national.shitposting.agency,mail.cock.li,993,mail.cock.li,587
netcourrier.com,mail.netcourrier.com,993,mail.netcourrier.com,465
nigge.rs,mail.cock.li,993,mail.cock.li,587
nuke.africa,mail.cock.li,993,mail.cock.li,587
nyu.edu,imap.gmail.com,993,smtp.gmail.com,587
o2.pl,poczta.o2.pl,993,poczta.o2.pl,465
one.com,imap.one.com,993,send.one.com,465
onenetbeyond.org,mail.autistici.org,993,smtp.autistici.org,465
onet.com.pl,imap.poczta.onet.pl,993,smtp.poczta.onet.pl,465
onet.eu,imap.poczta.onet.pl,993,smtp.poczta.onet.pl,465
@@ -136,11 +142,14 @@ opoczta.pl,imap.poczta.onet.pl,993,smtp.poczta.onet.pl,465
orange.fr,imap.orange.fr,993,smtp.orange.fr,465
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.at,imap-mail.outlook.com,993,smtp-mail.outlook.com,587
paranoici.org,mail.autistici.org,993,smtp.autistici.org,465
poczta.fm,poczta.interia.pl,143,poczta.interia.pl,465
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
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
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
@@ -150,9 +159,13 @@ redchan.it,mail.cock.li,993,mail.cock.li,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
southwales.ac.uk,imap.gmail.com,993,smtp.gmail.com,587
spoko.pl,imap.poczta.onet.pl,993,smtp.poczta.onet.pl,465
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
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
t-online.de,secureimap.t-online.de,993,securesmtp.t-online.de,465
techie.com,imap.mail.com,993,smtp.mail.com,587
@@ -162,6 +175,7 @@ tfwno.gf,mail.cock.li,993,mail.cock.li,587
tlen.pl,poczta.o2.pl,993,poczta.o2.pl,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
txstate.edu,outlook.office365.com,993,smtp.office365.com,587
uach.mx,imap.gmail.com,993,smtp.gmail.com,587
uoregon.edu,imap.uoregon.edu,993,smtp.uoregon.edu,587
uqtr.ca,outlook.office365.com,993,smtp.office365.com,587

mailcap → share/mailcap View File


mutt-wizard.muttrc → share/mutt-wizard.muttrc View File


Loading…
Cancel
Save