From 44c70edd8175acb1a0d717c32e4048265c65cb8a Mon Sep 17 00:00:00 2001 From: Vlad Doster Date: Sat, 21 Nov 2020 02:06:33 -0600 Subject: [PATCH 01/25] Update README.md - Fix formatting, typos, and make the format cohesive. - Move LICENSE to defacto spot and more prominent - Move dependencies sections to be a sub-section of the Install section since it was a bit confusing as to why the dependencies were after the Install section. --- README.md | 198 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 135 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 31118f1..4b5d99d 100644 --- a/README.md +++ b/README.md @@ -3,29 +3,52 @@ 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 enabling the ability to: + * view and write emails while you're away from + the internet + * make 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 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 +## Install -``` +#### Dependencies + +- `neomutt` - the email client. +- `isync` - downloads and syncs the mail. (required at install) +- `msmtp` - sends the email. +- `pass` - safely encrypts passwords (required at install) + +**Note**: 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`. + +```bash git clone https://github.com/LukeSmithxyz/mutt-wizard cd mutt-wizard sudo make install ``` -User of Arch-based distros can also install mutt-wizard from the AUR as [mutt-wizard-git](https://aur.archlinux.org/packages/mutt-wizard-git/). +A user of Arch-based distros can also install mutt-wizard from the AUR as +[mutt-wizard-git](https://aur.archlinux.org/packages/mutt-wizard-git/). + +## Usage -The mutt-wizard is run with the command `mw`. Once everything is setup, you'll use `neomutt` to access your mail. +The mutt-wizard runs via the command `mw`. Once setup is complete, you'll use +`neomutt` to access your mail. - `mw -a you@email.com` -- add a new email account - `mw -l` -- list existing accounts @@ -40,96 +63,145 @@ 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 - `-S` -- SMTP server port (otherwise assumed to be 587) -- `-m` -- Maximum number of emails to be kept offline. No maximum is default functionality. +- `-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 -- `-p` -- Add a Protonmail account -- `-f` -- Assume mailbox names and force account configuration without connecting online at all. +- `-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 - -- `neomutt` - the email client. -- `isync` - downloads and syncs the mail. (required at install) -- `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 - -- `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. -- `urlview` - outputs urls in mail to browser. - ## Neomutt user interface To give you an example of the interface, here's an idea: - `m` - send mail (uses your default `$EDITOR` to write) -- `j`/`k` and `d`/`u` - vim-like bindings to go down and up (or `d`/`u` to go down/up a page). +- `j`/`k` and `d`/`u` - vim-like bindings to go down and up (or `d`/`u` to go + down/up a page). - `l` - open mail, or attachment page or attachment - `h` - the opposite of `l` - `r`/`R` - reply/reply all to highlighted mail - `s` - save selected mail or selected attachment -- `gs`,`gi`,`ga`,`gd`,`gS` - Press `g` followed by another letter to change mailbox: `s`ent, `i`nbox, `a`rchive, `d`rafts, `S`pam, etc. -- `M` and `C` - For `M`ove and `C`opy: follow them with one of the mailbox letters above, i.e. `MS` means "move to Spam". -- `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. +- `gs`,`gi`,`ga`,`gd`,`gS` - Press `g` followed by another letter to change + mailbox: `s`ent, `i`nbox, `a`rchive, `d`rafts, `S`pam, etc. +- `M` and `C` - For `M`ove and `C`opy: follow them with one of the mailbox + letters above, i.e. `MS` means "move to Spam". +- `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 abook. - `?` - 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. -- +- `ctrl-b` - open a menu to select a URL you want to open in your browser. + +## Additional functionality + +- `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. +- `urlview` - Outputs URLs in an email to your 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. -- 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 (i.e. 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. Fewer + 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). - -mutt-wizard is free/libre software, licensed under the GPLv3. +See Luke's website [here](https://lukesmith.xyz). Email him at +[luke@lukesmith.xyz](mailto:luke@lukesmith.xyz). ## 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. - -## 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. +- 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 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 override this in your `muttrc` if + you wish. + +## Watch out for these things + +- Gmail accounts need to create an [App + Password](https://support.google.com/accounts/answer/185833?hl=en) to use + with _**less secure**_ applications. This password is single-use (i.e. 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 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. + - `isync` is not fully UTF-8 compatible, so non-Latin characters may be garbled + (although sync should succeed). `mw` will also not auto-create 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 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) +- [x] Add Mac OS/BSD compatibility + +- [x] 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) + +## License + +[mutt-wizard](https://github.com/LukeSmithxyz/mutt-wizard) is free/libre software. This program is released under the GPLv3 license, which you can find in the file [LICENSE](LICENSE). From 4228837d3dabd4ab11a55aeba1c052a9776497d2 Mon Sep 17 00:00:00 2001 From: Rodrigo Camacho Date: Mon, 23 Nov 2020 14:03:13 -0600 Subject: [PATCH 02/25] Formatting changes, precision to TFA google --- mw.1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mw.1 b/mw.1 index 3ed4d95..8c407e9 100644 --- a/mw.1 +++ b/mw.1 @@ -121,9 +121,11 @@ If you would like to help develop mutt-wizard for others, you are invited to add on mutt-wizard's Github or Gitlab pages. .TP .B Gmail accounts -Google will require you to allow "less-secure" (third party) applications or use 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 . +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 From 30c4647c98e2e04b86ef6189bf7974b1a3bc20bd Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 24 Dec 2020 20:40:17 -0500 Subject: [PATCH 03/25] don't readd same account. fix #558 --- bin/mw | 2 ++ 1 file changed, 2 insertions(+) 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 From a434ac50feb1f6e3142a18d5db0c22c8012cd05a Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 24 Dec 2020 20:43:27 -0500 Subject: [PATCH 04/25] fix #596 --- bin/mw | 1 + 1 file changed, 1 insertion(+) 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 From 33fd62bcf156b74ba3866e234425f637b71e1359 Mon Sep 17 00:00:00 2001 From: Novite5 Date: Wed, 30 Dec 2020 21:26:14 +0800 Subject: [PATCH 05/25] add Sina and Sohu Mail --- share/domains.csv | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/domains.csv b/share/domains.csv index 64dcf80..65251d6 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 @@ -220,8 +220,11 @@ rwth-aachen.de,mail.rwth-aachen.de,993,mail.rwth-aachen.de,587 sapo.pt,imap.sapo.pt,993,smtp.sapo.pt,587 seznam.cz,imap.seznam.cz,993,smtp.seznam.cz,465 shu.edu.cn,imap.shu.edu.cn,143,smtp.shu.edu.cn,25 +sina.com,imap.sina.com,993,smtp.sina.com,587 +sina.cn,imap.sina.cn,993,smtp.sina.cn,587 smail.inf.h-brs.de,imap.inf.h-brs.de,993,smtp.inf.h-brs.de,587 sms.ed.ac.uk,pod51015.outlook.com,993,pod51015.outlook.com,587 +sohu.com,imap.sohu.com,143,smtp.sohu.com,25 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 From f589cd4dfdd00f8521c09548b77cba6f995f89a5 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 31 Dec 2020 12:28:15 -0500 Subject: [PATCH 06/25] 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 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, From aa4fb999ebbe6e99ac5e083be372b3630354c8bc Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 1 Jan 2021 08:11:14 -0500 Subject: [PATCH 07/25] systemd fix, check for variables with whitespace --- bin/mailsync | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/mailsync b/bin/mailsync index 02e4f98..1d676b8 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -20,17 +20,17 @@ pgrep -x mbsync >/dev/null && { echo "mbsync is already running." ; exit ;} # 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` +eval "$(grep -h -- \ + "^\s*\(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 +case "$(readlink -f /sbin/init)" in + *systemd*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;; +esac export GPG_TTY=$TTY [ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" From 22acbeb3e5146ae9d04398169b4fb4aa57587804 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 1 Jan 2021 13:32:41 -0500 Subject: [PATCH 08/25] makefile fix --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1d8d362..7b78355 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ install: uninstall: for script in bin/*; do \ - rm -f $(DESTDIR)$(PREFIX)/bin/$$script; \ + rm -f $(DESTDIR)$(PREFIX)/$$script; \ done rm -rf $(DESTDIR)$(PREFIX)/share/mutt-wizard rm -f $(DESTDIR)$(MANPREFIX)/man1/mw.1 From 63466ad954d5763faa18039fe42ace56af03ce4c Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 2 Jan 2021 10:18:41 -0500 Subject: [PATCH 09/25] imap ssl off when unencrypted port given --- bin/mw | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 ;; From 4dbf70e40355b73b16a3b0b010960a0d1a681740 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 09:17:59 -0500 Subject: [PATCH 10/25] less gimicky feedback --- bin/mw | 12 +++++------- share/domains.csv | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) 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 From ca9f1a12ccbc01889fd2a1257462594e4d2ea272 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:13:48 -0500 Subject: [PATCH 11/25] use curl to login rm mbsync requirement for online storage --- README.md | 5 +++-- bin/mw | 17 ++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) 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" From 78030885b4e3153b69d408424beeb544adc093a8 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:25:09 -0500 Subject: [PATCH 12/25] fix --- bin/mw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ' ')" } From f83c45689b21fccb917fdb4c555280eaf19ef78f Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:34:00 -0500 Subject: [PATCH 13/25] temporary soydevery --- bin/mw | 6 ++++++ 1 file changed, 6 insertions(+) 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() { \ From 16de5dc350d06cd45338271a2286c0629ef20435 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:38:25 -0500 Subject: [PATCH 14/25] don't ask realname if not given; assume userid --- README.md | 2 +- bin/mw | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) 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 From 564c529f8ec3aa6697d966dde89abdf132012240 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 7 Jan 2021 17:04:08 -0500 Subject: [PATCH 15/25] curl redirects and times out --- bin/mailsync | 6 +----- bin/mw | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) 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 ' ')" } From c8f2aa2c529464306decbc2e21f1702d4bd9ae17 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 7 Jan 2021 17:38:40 -0500 Subject: [PATCH 16/25] close #566 --- share/mutt-wizard.muttrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc index a9484f3..2cb7c8e 100644 --- a/share/mutt-wizard.muttrc +++ b/share/mutt-wizard.muttrc @@ -3,7 +3,7 @@ # mutt-wizard will have this file sourced from your muttrc. # 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 mailcap_path = /usr/local/share/mutt-wizard/mailcap:$mailcap_path 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)" From 038b90bb46115c5696fdaee6fd05394ca14e7736 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 7 Jan 2021 18:11:35 -0500 Subject: [PATCH 17/25] tweaks cloe #367 --- bin/mw | 90 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 44 deletions(-) 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 From c05b6aa92c64728f8f2f80c5d31317e098346596 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 7 Jan 2021 18:35:06 -0500 Subject: [PATCH 18/25] final --- README.md | 55 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 003ff58..700de00 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ Specifically, this wizard: - `msmtp` - sends the email. - `pass` - safely encrypts passwords (required at install). -**Note**: 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 +**Note**: 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`. ```bash @@ -50,12 +50,19 @@ A user of Arch-based distros can also install mutt-wizard from the AUR as ### Optional Dependencies -- `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). +- `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. +- `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. +- `cronie` - (or any other major cronjob manager) to set up automatic mail + syncing. ## Usage @@ -185,38 +192,38 @@ See Luke's website [here](https://lukesmith.xyz). Email him at ## Watch out for these things -- Gmail accounts need to create an [App - Password](https://support.google.com/accounts/answer/185833?hl=en) to use - with _**less secure**_ applications. This password is single-use (i.e. for - setup) and will be stored and encrypted locally. Enabling third-party +- Gmail accounts need to create an +- [App Password](https://support.google.com/accounts/answer/185833?hl=en) to + use with _**less secure**_ applications. This password is single-use (i.e. + 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 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. + 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/) + 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 auto-create 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. +- `isync` is not fully UTF-8 compatible, so non-Latin characters may be garbled + (although sync should succeed). `mw` will also not auto-create 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 - [x] Add Mac OS/BSD compatibility - - [x] 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) - + ## License -[mutt-wizard](https://github.com/LukeSmithxyz/mutt-wizard) is free/libre software. This program is released under the GPLv3 license, which you can find in the file [LICENSE](LICENSE). +mutt-wizard is free/libre software. This program is released under the GPLv3 +license, which you can find in the file [LICENSE](LICENSE). From 913c877448158ca6a97d6090884fc9ec9a3d9c68 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 7 Jan 2021 20:55:43 -0500 Subject: [PATCH 19/25] detect all Xorgs #fixes #607 --- bin/mailsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mailsync b/bin/mailsync index 3fac7c5..980b015 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -42,7 +42,7 @@ case "$(uname)" in 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]\+")" + displays="$(pgrep -a 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." From d7fd47516f9283e70bd4d0e5f19391e161247919 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Fri, 8 Jan 2021 08:36:17 -0500 Subject: [PATCH 20/25] fix #615 --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 3f54e68365bdba9eaa59c496fd7c2a933f2f8081 Mon Sep 17 00:00:00 2001 From: Kr1ss Date: Fri, 8 Jan 2021 22:02:33 +0100 Subject: [PATCH 21/25] [README] add info and link to stable AUR package Since version tags/releases have been introduced lately, Arch users are now able to choose between a 'stable' and a 'development' package. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 700de00..bf17925 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ cd mutt-wizard sudo make install ``` -A user of Arch-based distros can also install mutt-wizard from the AUR as -[mutt-wizard-git](https://aur.archlinux.org/packages/mutt-wizard-git/). +A user of Arch-based distros can also install the current mutt-wizard release from the AUR as +[mutt-wizard](https://aur.archlinux.org/packages/mutt-wizard/), or the Github master branch, [mutt-wizard-git](https://aur.archlinux.org/packages/mutt-wizard-git/). ### Optional Dependencies From e5d7ac10f06f0d9dc35b02c6d546b5379b214d1f Mon Sep 17 00:00:00 2001 From: Cloud11665 Date: Sat, 16 Jan 2021 18:32:14 +0100 Subject: [PATCH 22/25] remove https://lukesmith.xyz/crypto --- FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FUNDING.yml b/FUNDING.yml index f8e6076..db8612d 100644 --- a/FUNDING.yml +++ b/FUNDING.yml @@ -1,3 +1,3 @@ github: lukesmithxyz -custom: ["https://lukesmith.xyz/donate", "https://paypal.me/lukemsmith", "https://lukesmith.xyz/crypto"] +custom: ["https://lukesmith.xyz/donate", "https://paypal.me/lukemsmith"] patreon: lukesmith From 3c3daa3508bc16ca9db03e7183e8cbefcb00f65f Mon Sep 17 00:00:00 2001 From: ret2hell Date: Sat, 16 Jan 2021 22:18:16 +0000 Subject: [PATCH 23/25] changed 'gpg --fullgenkey' to the correct command. --- bin/mw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)" ;} From 153c7994703af2494dbe4017161409345f438ae3 Mon Sep 17 00:00:00 2001 From: "Lorenzo IN3HBB (as3ii)" Date: Sun, 17 Jan 2021 00:05:29 +0100 Subject: [PATCH 24/25] added unitn.it related email infos possible email are: - username@studenti.unitn.it - username@ex-studenti.unitn.it - username@alumni.unitn.it - username@unitn.it --- share/domains.csv | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/domains.csv b/share/domains.csv index 65251d6..fb39143 100644 --- a/share/domains.csv +++ b/share/domains.csv @@ -12,6 +12,7 @@ airmail.cc,mail.cock.li,993,mail.cock.li,587 allergist.com,imap.mail.com,993,smtp.mail.com,587 alumni.bits-pilani.ac.in,imap.gmail.com,993,smtp.gmail.com,465 alumni.com,imap.mail.com,993,smtp.mail.com,587 +alumni.unitn.it,imap.gmail.com,993,smtp.gmail.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 @@ -93,6 +94,7 @@ ethancoe.com,mail.privateemail.com,993,mail.privateemail.com,465 ethz.ch,mail.ethz.ch,993,mail.ethz.ch,587 etu.upmc.fr,courriel.upmc.fr,993,smtps.upmc.fr,587 europe.com,imap.mail.com,993,smtp.mail.com,587 +ex-studenti.unitn.it,imap.gmail.com,993,smtp.gmail.com,587 fastmail.com,imap.fastmail.com,993,smtp.fastmail.com,465 fastmail.fm,imap.fastmail.com,993,smtp.fastmail.com,465 firemail.cc,mail.cock.li,993,mail.cock.li,587 @@ -241,6 +243,7 @@ student.tuwien.ac.at,mail.student.tuwien.ac.at,993,mail.student.tuwien.ac.at,587 student.uj.edu.pl,outlook.office365.com,993,smtp.office365.com,587 student.utwente.nl,imap.gmail.com,993,smtp.gmail.com,587 studenti.unipi.it,outlook.office365.com,993,smtp.office365.com,587 +studenti.unitn.it,imap.gmail.com,993,smtp.gmail.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 @@ -267,6 +270,7 @@ uni-jena.de,imap.uni-jena.de,993,smtp.uni-jena.de,587 unilodz.eu,outlook.office365.com,993,smtp.office365.com,587 unitybox.de,mail.unity-mail.de,993,mail.unity-mail.de,587 univ-ubs.fr,partage.univ-ubs.fr,993,partage.univ-ubs.fr,587 +unitn.it,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 usa.com,imap.mail.com,993,smtp.mail.com,587 From b11dcf53dccd33725c7458e884eeb6aa30dcaa4e Mon Sep 17 00:00:00 2001 From: dgrisham Date: Mon, 18 Jan 2021 15:56:28 -0700 Subject: [PATCH 25/25] mailsync: Check whether XDG_CONFIG_HOME is defined before defaulting to $HOME/.config for mutt dir --- bin/mailsync | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/mailsync b/bin/mailsync index 980b015..ecac6af 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -33,6 +33,8 @@ case "$(readlink -f /sbin/init)" in esac export GPG_TTY=$TTY +muttconfig="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" + [ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" # Settings are different for MacOS (Darwin) systems. @@ -58,7 +60,7 @@ esac 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) + 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 "$muttconfig/.mailsynclastrun" 2> /dev/null) newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) if [ "$newcount" -gt "0" ]; then notify "$acc" "$newcount" & @@ -91,4 +93,4 @@ wait notmuch new 2>/dev/null #Create a touch file that indicates the time of the last run of mailsync -touch "$HOME/.config/mutt/.mailsynclastrun" +touch "$muttconfig/.mailsynclastrun"