Mimir's Head
Writing about this, that, and the other: projects, essays, art, design, and strange things. If you'd like to stay updated, follow the RSS feed!
For a complete listing of all posts, see here.
For updates to the Annotated Mountain Goats, see here.
"high blows Heimdallr, the horn is aloft
Odin speaks with Mimir's head
trembles Yggdrasil's towering ash
the old tree wails when the ettin is loosed."
On this page
- 2019
- 2018
I think you'll understand if you see the patient
One of our CT techs put this up in the scanner control room. I love it.
On tattoos
thanks to Suze Shore
Yes.
Migrating from Thunderbird to mutt, part 3: using email (mutt)
If you haven't read part 1 and want to receive mail, see here!
If you haven't read part 2 and want to send mail, see here!
The totality of configuring mutt
is complex, but I want to help provide
the basics of configuring a two-account system that can send and receive
email. Once you can do that, you can figure out the rest as you explore the
program, read the manual, and decide what
you like and need. At this point, this isn't particularly different than
configuring any other multi-account mutt
profile.
Here's a basic .muttrc
, containing only the necessary elements for multiple
accounts and a few options that I think are nearly essential. There's lots
more that could or should be in here for a full-fledged setup, but I don't
want to confuse things unnecessarily!
# Who am I?
set realname = "Buckaroo Banzai"
set use_from
# Accounts
folder-hook home 'source ~/.mutt/muttrc.home'
folder-hook work 'source ~/.mutt/muttrc.work'
# Start on home account
source ~/.mutt/muttrc.home
# Mailboxes
set mbox_type = Maildir
set copy
mailboxes ~/mail/home
mailboxes ~/mail/work
This requires two additional files which will be loaded whenever you are in
directories which match the regex home
and work
, which we previously set
up to be the locations mbsync
delivers mail to. You can call them whatever
you want and put wherever you want; putting them in a ~/.mutt
directory and
calling them muttrc.{home,work}
is just the pattern I use.
These set the values for each folder:
# muttrc file for home account
set from = "plugh@xyzzy.org"
set hostname = "xyzzy.org"
set folder = "~/mail/home"
set signature = "~/.signature"
set sendmail = "/usr/bin/msmtp -a home"
set spoolfile = "+Inbox"
set postponed = "+Drafts"
set record = "+Sent"
set mbox = "+Archives/`date +%Y`"
save-hook . "+Archives/%[%Y]"
set trash = "+Trash"
color status green default
and
# muttrc file for work account
set from = "thud@yoyodyne.com"
set hostname = "yoyodyne.com"
set folder = "~/mail/work"
set signature = "~/.signature-work"
set sendmail = "/usr/bin/msmtp -a work"
set spoolfile = "+Inbox"
set postponed = "+Drafts"
set record = "+Sent"
set mbox = "+/Archives/`date +%Y`"
save-hook . "+Archives/%[%Y]"
set trash = "+Trash"
color status blue default
I like changing the status colors to help remind myself where I am — the first color is the color of the text, the second is the color of the background — but this is obviously not necessary.
Unfortunately, even if both accounts technically use the same regex (for
example, both use set spoolfile = "+Inbox"
, "+
" being a shortcut for
$folder
), you can't simply set this once in .muttrc
and be done. Mailbox
shortcut expansion is done when
the file is loaded, not when the regex is evaluated, so setting it once in
.muttrc
wouldn't allow it to switch between mailboxes when the folder-hook
is evaluated.
mutt
's default save behavior is to append to $mbox
without sorting
archived mail further. I like Thunderbird's behavior of sorting by year, and
the above mbox
and save-hook
settings accomplish this. This solution is
thanks to Daniel Schömer on
mutt-users
and I
have to admit that I don't fully understand it (if you do, I'd love an
explanation). It appears to be smart enough to archive
based in the year the message was sent, and that's exactly what I wanted.
Hope this series was helpful! If you have questions, please feel free to email me.
Migrating from Thunderbird to mutt, part 2: sending email (msmtp)
If you haven't read part 1 and want to receive mail, see here!
For configuring mutt
for multiple accounts, see part
3!
Fortunately, configuring msmtp
to send mail is substantially easier than
getting mail. Here's an example ~/.msmtprc
:
defaults
logfile ~/path/to/msmtp.log
account home
host mail.xyzzy.org
port 587
protocol smtp
from plugh@xyzzy.org
auth on
user plugh
passwordeval gpg2 -q --for-your-eyes-only --no-tty --batch -d ~/.mail-home.gpg
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account work
host localhost
port 1025
protocol smtp
from thud@yoyodyne.com
auth login
user thud
passwordeval gpg2 -q --for-your-eyes-only --no-tty --batch -d ~/.mail-work.gpg
account default : home
where, similar to before, mail.xyzzy.org
, plugh@xyzzy.org
, plugh
,
thud@yoyodyne.com
, and thud
are the locations of your home SMTP server, your
home email address, your home login, your work email, and your work login
respectively. Usually passwordeval
can use the same command as for mbsync
,
assuming your IMAP and SMTP passwords are the same. Also, you don't have to
use the same account names as you did with mbsync
, but it's probably easier
if you do.
The bottom line sets the account default, meaning that if msmtp
is run with
no other qualifications, mail will be set using that account (here, home
).
To test your configuration, you can try
$ echo "cheese" | msmtp -a work bigboote@lectroids.com
obviously using a different email address that you can check. If it goes through and works for both accounts, you're good!
Additionally, for log maintenance, I added the following to my crontab
,
similarly to before with mbsync
:
@weekly cd $HOME/mail/logs && echo "$(tail -1000 msmtp.log)" > msmtp.log
For configuring mutt
for multiple accounts, see part
3!
Migrating from Thunderbird to mutt, part 1: getting email (mbsync + davmail)
I've become increasingly frustrated with the limitations of Thunderbird, and
finally started taking the steps to migrate to a more powerful email client,
mutt
. This had been daunting for some time as Thunderbird handles a lot of
the behind-the-scenes work for you — retrieving email (it's a mail delivery
agent, MDA), sending email (and a mail transfer agent, MTA), and other things
besides in addition to being a mail user agent (MUA). mutt
, in contrast, is
more or less a straight MUA, so you have to figure out how to fill those
roles.
Fortunately, there's great software and lots of guides out there to help with this. Unfortunately, my work's mailserver is Micro$oft Exchange, which uses Exchange ActiveSync (EAS) with IMAP and SMTP disabled. I wrote this up to hopefully help other users in similar situations configure their systems successfully.
Overview
I use Ubuntu GNU/Linux; while the specifics and installation might be different on other platforms, I think the general framework will hold. My kernel and release info:
$ uname -rio
4.4.0-128-generic x86_64 GNU/Linux
$ lsb_release -dc
Description: Ubuntu 16.04.4 LTS
Codename: xenial
Here's the way my system is now set up:
I'm very grateful that davmail
exists. It's a simple Java program that
provides an IMAP/SMTP frontend locally and then interacts with an EAS server.
I'm not aware of a good alternative — if you are, please reach
out!
mbsync
and msmtp
are wonderful, lightweight IMAP and SMTP clients,
respectively. mbsync
is sometimes referred to as isync
, its historical
name. The installation package is still isync
on many platforms (including
Ubuntu), but the executable is mbsync
. You can certainly use more classic
MTAs like sendmail
, but for a single-user system my impression is that it's
unnecessarily complex.
Installation
On Ubuntu, all are available on the repos as of 18.04 LTS (bionic beaver). For
16.04 LTS, mbsync
and msmtp
are available, however, some of the features
used in my configuration of mbsync
are only available in newer versions, and
so I compiled from source. davmail
has a .deb
package which you can easily
install with dpkg
on its website.
If you're on Ubuntu 18.04 LTS, you should be able to simply
$ sudo apt install davmail isync msmtp mutt
without issue, but as upgrades won't be released until late July 2018, I haven't tried this yet.
Incoming mail (EAS/IMAP) — mbsync + davmail
davmail
installation is blessedly uncomplicated. By default, it accepts IMAP
and SMTP locally on ports 1143 and 1025 respectively. You have to set the URL
for your Outlook Web Access (the way you access your email in a browser, which
should end with /owa/
— for example, https://mail.yoyodyne.com/owa/
),
and the destination for davmail
's logfiles. All of this information is
stored in .davmail.properties
and can be easily re-edited there.
To have davmail
start on boot without the tray icon, you can add
/usr/bin/davmail -notray
to your startup applications.
mbsync
has a more complex setup that I don't begin to fully understand.
However, once configured, it runs easily, and you can easily have multiple
accounts. 1 A two-account .mbsyncrc
using davmail
looks like
this:
IMAPAccount home
Host mail.xyzzy.org
Port NNN
User plugh
PassCmd "gpg2 -q --for-your-eyes-only --no-tty --batch -d ~/.mail-home.gpg"
SSLType STARTTLS
IMAPStore home-remote
Account home
MaildirStore home-local
Subfolders Verbatim
Path ~/mail/home/
Inbox ~/mail/home/Inbox
Channel home
Master :home-remote:
Slave :home-local:
Patterns * !Archives !Lists
Create Both
Expunge Both
SyncState *
##########
IMAPAccount work
Host localhost
Port 1143
User thud
PassCmd "gpg2 -q --for-your-eyes-only --no-tty --batch -d ~/.mail-work.gpg"
SSLType None
AuthMechs LOGIN
IMAPStore work-remote
Account work
MaildirStore work-local
Subfolders Verbatim
Path ~/mail/work/
Inbox ~/mail/work/Inbox
Channel work
Master :work-remote:
Slave :work-local:
Patterns * !Archives
Create Both
Expunge Both
SyncState *
where mail.xyzzy.org
, NNN
, and thud
represent your mailserver address,
port number, and Exchange username, respectively.
A few comments:
- You can call your accounts whatever you want, I just chose
home
andwork
as examples. You just have to be consistent throughout. -
You can put any command that generates your password in
PassCmd
(for example, accessing the system keyring). To generate an encrypted password file with GPG, one easy way is$ echo 'password' | gpg2 -r plugh@xyzzy.org -e -o output.gpg
On most terminals, prepending a space prevents this from being stored in your history, but it's worth checking and deleting the entry if possible so your password isn't stored anywhere in plaintext.
Subfolders Verbatim
creates an identical folder tree for your local Maildir as what you have on your mail server. There are lots of other options!- You can of course choose different locations for
Path
andInbox
than these. Patterns *
will match all of your remote folders and treat them as Maildirs, meaning that locally those files will havecur
,new
, andtmp
subdirectories. You can exclude directories by prefixing them with!
. Here, I have subdirectories ofArchives
andLists
which are each Maildirs, but I want to exclude those so they aren't treated as Maildirs. The subfolders are still synced without issues.- For the work account, the
Host
andPort
fields are the defaults fordavmail
. - If you have to log in with a domain, you have to use two backslashes (e.g.
DOMAIN\\thud
) to escape the backslash. - While you're testing things, you may want to comment out
Expunge Both
. This actually removes deleted files rather than simply marking them as being deleted, so it's more permanent. - For the
work
AuthMechs
,davmail
acceptsLOGIN
but not other forms without more configuration. I don't think there's much issue with this on a small system as all the data transfer is local, but there may be ways to encrypt it locally as well if you like.
And you're set! Now, to sync, you can run mbsync home
, mbsync work
, or
mbsync -a
for all mailboxes. I have it set to sync my mail every two minutes
with the following entries in my crontab
:
*/2 * * * * mbsync -a 2>>$HOME/mail/logs/mbsync.log
@weekly cd $HOME/mail/logs && echo "$(tail -1000 mbsync.log)" > mbsync.log
You can omit the logging of stderr
and the second entry (which just
periodically trims the log) if you don't want any logging.
For sending mail, see part 2!
For configuring mutt
for multiple accounts, see part
3!
Footnotes
-
Packaged versions of
mbsync
(as of June 2018, v1.3.0) include a bug which leads to duplicate messages when usingdavmail
. This is not currently fully patched, but is easy to solve if you build from source. Obtain it and its dependencies as follows:$ git clone https://git.code.sf.net/p/isync/isync $ sudo apt install libssl-dev
The offending code is in
drv_imap.c
. As of v1.3.1, this is partially patched, but on line 2925 (which reads"UID FETCH *:* (UID) );"
there's another error. To fix this, replace '*:*' with '*' on that line, which should then read"UID FETCH * (UID) );"
. You can then build with$ ./autogen.sh $ ./configure $ make $ sudo make install
as described in the README, which will put the resulting binary in
/usr/bin/local
. Hopefully this will be fully patched and packaged soon! Note that if you usecron
to callmbsync
that/usr/local/bin
may not be in its path, or that it may come after any version that was installed by your package manager, meaning that you may need to specify/usr/local/bin/mbsync
or modifycron
's$PATH
. ↩