Преглед изворни кода

Merge branch 'master' into patch-1

pull/400/head
Luke Smith пре 4 година
committed by GitHub
родитељ
комит
e2ccf8671f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
9 измењених фајлова са 56 додато и 31 уклоњено
  1. +3
    -0
      FUNDING.yml
  2. +6
    -6
      README.md
  3. +11
    -9
      bin/mailsync
  4. +21
    -10
      bin/mw
  5. +1
    -1
      bin/openfile
  6. +2
    -2
      mw.1
  7. +10
    -2
      share/domains.csv
  8. +1
    -0
      share/mailcap
  9. +1
    -1
      share/mutt-wizard.muttrc

+ 3
- 0
FUNDING.yml Прегледај датотеку

@@ -0,0 +1,3 @@
github: lukesmithxyz
custom: ["https://lukesmith.xyz/donate", "https://paypal.me/lukemsmith", "https://lukesmith.xyz/crypto"]
patreon: lukesmith

+ 6
- 6
README.md Прегледај датотеку

@@ -3,13 +3,13 @@
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 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

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 stores locally your password for easy remote access, accessible only by your GPG key
- 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
- Can automatically set mail updates as often as you want to sync your mail and update you when new mail arrives
@@ -48,7 +48,7 @@ There's a chance of errors if you use a slow-release distro like Ubuntu, Debian

- `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, although the included `mailsync` script does this for you.
- `libnotify`/`libnotify-bin` - allows notifications when syncthing mail with `mailsync`
- `libnotify`/`libnotify-bin` - allows notifications when syncing mail with `mailsync`
- `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).
@@ -105,12 +105,12 @@ mutt-wizard is free/libre software, licensed under the GPLv3.

## 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.
- Protonmail bridge is prone to timing out. Watch out for this while adding an account. If the bridge times out, try again.
- 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.

## To-do

- Add ~~Mac OS~~/BSD compatibility (the script is confired to work for Mac OS now)
- Add ~~Mac OS~~/~~BSD~~ compatibility (the script is confirmed to work for Mac OS and FreeBSD now)
- ~~Out-of-the-box compatibility with Protonmail Bridge~~ (I believe this is done, but more bug-testing is welcome since I don't have PM)

+ 11
- 9
bin/mailsync Прегледај датотеку

@@ -12,24 +12,25 @@ ping -q -c 1 1.1.1.1 > /dev/null || { echo "No internet connection detected."; e
command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script."

# Required to display notifications if run as a cronjob:
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
export DISPLAY=:0.0

# For individual configurations:
[ -d "$HOME/.local/share/password-store" ] && export PASSWORD_STORE_DIR="$HOME/.local/share/password-store"
pgrep i3blocks >/dev/null && STATUSBAR="i3blocks" || STATUSBAR="dwmblocks"

# Settings are different for MacOS (Darwin) systems.
if [ "$(uname)" = "Darwin" ]; then
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\"" ;}
else
notify() { notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account." ;}
messageinfo() { notify-send --app-name="mutt-wizard" "📧$from:" "$subject" ;}
fi

# Check account for new mail. Notify if there is new content.
syncandnotify() {
acc="$(echo "$account" | sed "s/.*\///")"
mbsync "$acc"
mbsync "$opts" "$acc"
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
@@ -37,8 +38,8 @@ syncandnotify() {
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')
notify-send --app-name="mutt-wizard" "📧$from:" "$subject" &
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
}
@@ -47,11 +48,13 @@ syncandnotify() {
if [ "$#" -eq "0" ]; then
accounts="$(awk '/^Channel/ {print $2}' "$HOME/.mbsyncrc")"
else
for arg in "$@"; do
[ "${arg%${arg#?}}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1
done
accounts=$*
fi

echo " 🔃" > /tmp/imapsyncicon_"$USER"
( pkill -RTMIN+12 "${STATUSBAR:?}" >/dev/null 2>&1 ) 2>/dev/null
( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null

# Parallelize multiple accounts
for account in $accounts
@@ -60,8 +63,7 @@ do
done

wait
rm -f /tmp/imapsyncicon_"$USER"
( pkill -RTMIN+12 "${STATUSBAR:?}" >/dev/null 2>&1 ) 2>/dev/null
( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null

notmuch new 2>/dev/null



+ 21
- 10
bin/mw Прегледај датотеку

@@ -3,11 +3,11 @@
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 <yourgpgemail>\`.\\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\` must be installed to run mutt-wizard.\\n" && exit
! 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
@@ -50,12 +50,11 @@ $starttlsoff
"
mbsync_profile="IMAPStore $title-remote
Host $imap
Port $iport
Port $iport
User $login
PassCmd \"pass mutt-wizard-$title\"
AuthMechs LOGIN
SSLType $ssltype
AuthMech LOGIN
CertificateFile $sslcert

MaildirStore $title-local
@@ -88,6 +87,11 @@ 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
@@ -101,14 +105,20 @@ mutt_profile="# vim: filetype=neomuttrc
# muttrc file for account $title
set realname = \"$realname\"
set from = \"$fulladdr\"
set sendmail = \"$prefix/bin/msmtp -a $title\"
set sendmail = \"msmtp -a $title\"
alias me $realname <$fulladdr>
set folder = \"imaps://$fulladdr@$imap:$iport\"
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 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
@@ -127,6 +137,7 @@ 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"
@@ -137,7 +148,7 @@ askinfo() { \
search_query=$domain
case "$domain" in
protonmail.com|protonmail.ch|pm.me)
search_query='protonmail.com' && break;;
search_query='protonmail.com' && return 1;;
*)
while : ; do
printf "\nIs your email hosted with Protonmail? [yes/no] "
@@ -292,7 +303,7 @@ choosecron() { ! pgrep cron >/dev/null && echo "No cron manager running. Install
read -r minnum
printf "\033[0m"
done
(crontab -l; echo "*/$minnum * * * * $(type mailsync | cut -d' ' -f3)") | crontab - &&
(crontab -l; echo "*/$minnum * * * * $(type mailsync | cut -d' ' -f3)") >/dev/null | crontab - &&
echo "Cronjob added. Mail will sync every $minnum minutes. Be sure you have your cron manager running."
fi ;}

@@ -322,7 +333,7 @@ name=$realname
primary_email=$fulladdr
[new]
tags=unread;inbox;
ignore=
ignore=.mbsyncstate;.uidvalidity
[search]
exclude_tags=deleted;spam;
[maildir]
@@ -331,7 +342,7 @@ synchronize_flags=true
gpg_path=$GPG"
echo "$nmbasic" > "$NOTMUCH_CONFIG" ;}

trap 'echo -e "\033[0m\n"; exit' STOP INT ABRT KILL
trap 'echo -e "\033[0m\n"; exit' INT ABRT

case "$1" in
ls) list ;;


+ 1
- 1
bin/openfile Прегледај датотеку

@@ -1,7 +1,7 @@
#!/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"
[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid xdg-open"
mkdir -p "/tmp/$USER-mutt-tmp"
file="/tmp/$USER-mutt-tmp/$(basename "$1")"
rm -f "$file"


+ 2
- 2
mw.1 Прегледај датотеку

@@ -6,7 +6,7 @@ mw \- mutt-wizard \- autoconfigure email accounts for neomutt and isync
<command>
.SH DESCRIPTION
.B mw
takes a user email account and sets up a terminal-based email interface with it for
takes a user email account and sets up a terminal-based email interface for it with
.B neomutt.
This can include offline email with
.B isync/mbsync
@@ -56,7 +56,7 @@ Neither
.B delete
or
.B purge
will delete downloaded mail for for safety (and time)'s sake. If you want to delete downloaded mail, do so manually by removing it from the directory above.
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.
.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


+ 10
- 2
share/domains.csv Прегледај датотеку

@@ -4,6 +4,7 @@ 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
ad.unsw.edu.au,outlook.office365.com,993,smtp.office365.com,587
adexec.com,imap.mail.com,993,smtp.mail.com,587
airmail.cc,mail.cock.li,993,mail.cock.li,587
allergist.com,imap.mail.com,993,smtp.mail.com,587
@@ -44,6 +45,7 @@ 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
clarkson.edu,imap.gmail.com,993,smtp.gmail.com,587
clasnet.sunyocc.edu,outlook.office365.com,993,smtp.office365.com,587
clerk.com,imap.mail.com,993,smtp.mail.com,587
clubmember.org,imap.mail.com,993,smtp.mail.com,587
cmail.carleton.ca,imap-mail.outlook.com,993,smtp-mail.outlook.com,587
@@ -87,6 +89,7 @@ forthnet.gr,mail.forthnet.gr,993,smtp-auth.forthnet.gr,465
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
gcc.edu,imap-mail.outlook.com,993,smtp-mail.outlook.com,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
@@ -166,6 +169,7 @@ kipras.org,mail.kipras.org,993,mail.kipras.org,587
krutt.org,mail.autistici.org,993,smtp.autistici.org,465
kth.se,webmail.kth.se,993,smtp.kth.se,587
lavabit.com,lavabit.com,993,lavabit.com,587
librem.one,imap.librem.one,993,smtp.librem.one,465
linuxmail.org,imap.mail.com,993,smtp.mail.com,587
live.com,imap-mail.outlook.com,993,smtp-mail.outlook.com,587
live.de,imap-mail.outlook.com,993,smtp-mail.outlook.com,587
@@ -236,6 +240,7 @@ 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
st.amu.edu.pl,outlook.office365.com,993,smtp.office365.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
@@ -243,7 +248,7 @@ 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
studenti.unipi.it,outlook.office365.com,995,smtp.office365.com,587
studenti.unipi.it,outlook.office365.com,993,smtp.office365.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
@@ -301,4 +306,7 @@ zaclys.net,mail.zaclys.net,993,mail.zaclys.net,465
zoho.com,imap.zoho.com,993,smtp.zoho.com,465
zohomail.eu,imap.zoho.eu,993,smtp.zoho.eu,465
ymail.com,imap.mail.yahoo.com,993,smtp.mail.yahoo.com,465
gcc.edu,imap-mail.outlook.com,993,smtp-mail.outlook.com,587
unilodz.eu,outlook.office365.com,993,smtp.office365.com,587
ethz.ch,mail.ethz.ch,993,mail.ethz.ch,587
bocken.org,imap.gmail.com,993,smtp.gmail.com,465
vxempire.xyz,vxempire.xyz,993,vxempire.xyz,587

+ 1
- 0
share/mailcap Прегледај датотеку

@@ -5,3 +5,4 @@ image/*; openfile %s ;
video/*; setsid mpv --quiet %s &; copiousoutput
application/pdf; openfile %s ;
application/pgp-encrypted; gpg -d '%s'; copiousoutput;
application/pgp-keys; gpg --import '%s'; copiousoutput;

+ 1
- 1
share/mutt-wizard.muttrc Прегледај датотеку

@@ -46,7 +46,7 @@ bind index U undelete-message
bind index L limit
bind index h noop
bind index l display-message
bind index <space> tag-entry
bind index,query <space> tag-entry
#bind browser h goto-parent
macro browser h '<change-dir><kill-line>..<enter>' "Go to parent folder"
bind index,pager H view-raw-message


Loading…
Откажи
Сачувај