Containerize your email!

ghostbar
ghostbar
Published in
3 min readFeb 10, 2017

My tech-related email is a Riseup account and I do prefer to read it using mutt and have it all together with a nice gnupg setup. That’s where I receive and send all my Debian and Alpine Linux related emails so I would prefer to be able to sign my communications. Because of this (and the fact my current daily machine is a MacOS) I had a small VM running Debian over VirtualBox, and this worked for a while, until 8GB of RAM were not enough for keeping my system happy with all the things I had open at the same time -we have issues closing things, ain’t am right?-.

So, coming from a background like mine where I use docker every single day for everything I decided to containerize my email.

Did you expect me to show something different than my spam folder? Really?

Downloading the emails

First things first, I containerized offlineimap. My original setup was using it since is faster and more reliable downloading my emails. It’s already on alpine so I just had to install it and then got it running making sure the configs were in the right place, which I already had. That’s how resnullius/docker-offlineimap got born:

docker run --rm \ 
-v /etc/localtime:/etc/localtime \
-v $PWD/configs:/Configs \
-v $PWD/secrets:/Secrets \
-v $PWD/Mail:/Mail \
resnullius/offlineimap

I know it does not looks that easy, but there’s an offlineimaprc to be used as example in the README, something like this should get you going:

[general]
ui = ttyui
accounts = riseup
maxsynaccounts = 1
maxage = 365

[Account riseup]
localrepository = riseup-local
remoterepository = riseup-remote
autorefresh = 1
quick = 10

[Repository riseup-local]
type = Maildir
localfolders = /Mail/riseup

[Repository riseup-remote]
type = IMAP
remotehost = mail.riseup.net
remoteuser = user
remotepassfile = /Secrets/riseup.pass
sslcacertfile = /Secrets/riseup-ssl-certs.crt
keepalive = 60
holdconnectionopen = yes

Yeah, that’s why /Secrets exists, so you don’t have to input your password. Please, use veracrypt for that folder.

Reading and sending emails

Then it came the actual reading and sending. I’ve been using mutt in combination with msmtp and it’s been working like a charm, following the same structure I gave to resnullius/docker-offlineimap I decided to keep configs and secrets separate, then resnullius/docker-mutt got born and works like this:

docker run --rm -ti \
-v /etc/localtime:/etc/localtime \
-v ~/.gnupg:/home/user/gnupg \
-v $PWD/configs:/Configs \
-v $PWD/secrets:/Secrets \
-v $PWD/Mail:/Mail \
resnullius/mutt

What a beauty, right? There’s just an issue: I haven’t been able to make it work with gnupg2, so this will be updated as soon as I can make it work. Something related to the way the pinentry works on branch 2.1.x.

In the meanwhile, it works for downloading, reading and sending email from your terminal, wherever you are. ❤

Oh yeah, you can read it from your phone too, with GPG support and all.

--

--