From f589cd4dfdd00f8521c09548b77cba6f995f89a5 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 31 Dec 2020 12:28:15 -0500 Subject: workable mailsync readded to enable autosync the new script manually searches for environmental variables so that it can work from a cronjob and additionally searches for all Xorg displays on Linux so that the display notification should appear correctly no doubt there will be more bugs, but this is what the people want and it's worth working out --- README.md | 107 +++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 25 deletions(-) (limited to 'README.md') 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 -- cgit v1.2.3 From ca9f1a12ccbc01889fd2a1257462594e4d2ea272 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:13:48 -0500 Subject: use curl to login rm mbsync requirement for online storage --- README.md | 5 +++-- bin/mw | 17 ++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index fc6999a..46c4a36 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,10 @@ The mutt-wizard is run with the command `mw`. Once everything is setup, you'll u ## Dependencies - `neomutt` - the email client. -- `isync` - downloads and syncs the mail. (required at install) +- `curl` - tests connections (required at install). +- `isync` - downloads and syncs the mail (required if storing IMAP mail locally). - `msmtp` - sends the email. -- `pass` - safely encrypts passwords (required at install) +- `pass` - safely encrypts passwords (required at install). There's a chance of errors if you use a slow-release distro like Ubuntu, Debian or Mint. If you get errors in `neomutt`, install the most recent version manually or manually remove the offending lines in the config in `/usr/share/mutt-wizard/mutt-wizard.muttrc`. diff --git a/bin/mw b/bin/mw index 3586df7..f009e90 100755 --- a/bin/mw +++ b/bin/mw @@ -199,9 +199,8 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_ # On Ubuntu/Debian, a link is needed since they use an older version. command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null - # Create the mbsync config file. - mkdir -p "${mbsyncrc%/*}" - echo "$mbsync_profile" >> "$mbsyncrc" + # Create the mbsync config file if local account. + [ -z "${online+x}" ] && mkdir -p "${mbsyncrc%/*}" && echo "$mbsync_profile" >> "$mbsyncrc" # Create a muttrc for viewing mail. echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc" @@ -230,14 +229,10 @@ Junk Trash Sent Archive" && return 0 - if mailboxes="$(mbsync -l "$fulladdr" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then - [ -n "${online+x}" ] && sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu - return 0 - else - echo "$mailboxes" - echo "Log-on not successful." - return 1 - fi ;} + info="$(curl -s --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" || + { echo "Log-on not successful." ; exit 1 ;} + mailboxes="$(echo "$info" | sed "s/.*\" //" | tr -d ' ')" +} finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" sed -ibu "/$marker/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu" -- cgit v1.2.3 From 16de5dc350d06cd45338271a2286c0629ef20435 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:38:25 -0500 Subject: don't ask realname if not given; assume userid --- README.md | 2 +- bin/mw | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 46c4a36..a68e298 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ The mutt-wizard is run with the command `mw`. Once everything is setup, you'll u #### Providing arguments - `-u` -- Give an account username if different from the email address. -- `-n` -- A real name to be used by the account. Put in quotations if multiple words +- `-n` -- A real name to be used by the account. Put in quotations if multiple words. - `-i` -- IMAP server address - `-I` -- IMAP server port (otherwise assumed to be 993) - `-s` -- SMTP server address diff --git a/bin/mw b/bin/mw index 9950fae..0c00e53 100755 --- a/bin/mw +++ b/bin/mw @@ -180,8 +180,7 @@ askinfo() { \ [ -z "$smtp" ] && echo "Give your email server's SMTP address (excluding the port number):" && read -r smtp [ "$sport" = 465 ] && tlsline="tls_starttls off" - [ -z "$realname" ] && echo "Give the name you would like to be identified by on the email account:" && - read -r realname + [ -z "$realname" ] && realname="${fulladdr%%@*}" login="${login:-$fulladdr}" if [ -n "${password+x}" ]; then createpass -- cgit v1.2.3