Ubuntu Jaunty command line email: Sup, OfflineIMAP and MSMTP

Recently I’ve been getting increasingly frustrated with both Thunderbird. Don’t get me wrong, it is an excellent email solution, but lately I’ve been finding that it is slowing down due to the amount of emails I have. I do have a webmail package attached to it, which I use of Thunderbird has slowed to a grinding halt, but sometimes, and as hard as this may be to believe, I’m not connected to the internets!

Also, using Thunderbird is just not geeky enough.

So I was looking for something better, something quicker that allowed me to download emails, but keep in sync my IMAP. And don’t forget, something truly dweeby. For me, this meant the command line. I find the more I use Linux the more I am drifting towards the command line as a way of getting things done.

After a bit of searching around, I found a Rails package called Sup. This looked like the ideal solution from my point of view. The authors seemed to be coming from the same head space I am regarding email, so I thought I’d give it a try.

After several hours hacking about, I now have it fully working, and even sending email, and I’ll outline the steps I took to get it up and running. I’m running Xubuntu Jaunty, but hopefully this will apply to most Ubuntu and Debian versions.

Command line email: Sup installation

Obviously, the first thing to do is to install Sup itself. For this I followed the instructions on the Sup WIKI for Debian/Ubuntu. I had absolutely no problems with these instructions, but for the sake of ease on your behalf, I’ll outline them below:

Firstly, you’ll need to install Ruby and the Build Essentials

sudo aptitude install ruby-full build-essential

Next, you’ll have to install Ruby Gems. You can find and download the latest Gems version from
http://rubyforge.org/frs/?group_id=126. At the time of writing, it is 1.3.5

wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar -zxvf rubygems-1.3.5.tgz
cd rubygems-1.3.5/
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system

Note: for me, “sudo gem update –system” didn’t update anything

Now we have Ruby and Ruby Gems installed, we can install Sup

sudo aptitude install libncurses5-dev
sudo gem install sup

For me, there were no problems with the install. If you are having problems, you might want to check out the Sup Wiki.
If correctly installed, you can now run Sup


When you first run Sup, your are greeted by a blank screen, not very exciting, but you can have a play as lined out in the New Users Guide.

Downloading Email: OfflineIMAP

Whilst is is all very well having a blank screen, at some point you might just want to actually use it to connect to your email. My main email is an IMAP account on my own server. Sup lets you connect directly to the IMAP server, however, Sup admits it is “very slow due mostly to Ruby’s IMAP library” and instead recommends using something like OfflineIMAP to mirror your IMAP server. Well, that’s what I decided to do.

Installing OfflineIMAP couldn’t be simpler on Ubuntu:

sudo apt-get install offlineimap

You will need to create a configuration file in your home directory. The name of the file should be .offlineimaprc an example of which is below

accounts = robsearles
[Account robsearles]
localrepository = Local
remoterepository = Remote
[Repository Local]
type = Maildir
localfolders = ~/Mail/robsearles
[Repository Remote]
type = IMAP
remotehost = mail.ibrow.com
remoteuser = username
remotepass = password

This is relatively self explanatory, but you can get more info at the OfflineIMAP Wiki. The three key things to note here are firstly in [Repository Local] the type is “Maildir” we will need this later when telling Sup the mailbox format type. Next the location of localfolders will be needed by Sup to find these emails. Finally, under [Repository Remote] we have included a remotepass. This is so we can run OfflineIMAP as a non-interactive cron job.

You will need to create your local mail directory. The directory I have specified is purely arbitory and you can specify what you want.

Now, test your configuration file by running


You should hopefully see a load of stuff happening, and the OfflineIMAP closing. Huzzah! It works. If not, you may have to have a play around with your config file some more.

Now you have it working, set up a cron job to automatically sync email. My crontab looks like this:

*/5 * * * * offlineimap

This basically sets OfflineIMAP to run every 5 minutes

Viewing Email: Sup configuration

Sup has a really easy to follow interactive configuration system. Simply run


and follow the prompts, when it asks you for sources, you will want to specify “1. Add a new source”. Now, this is where those first two key values in the OfflineIMAP configuration are needed. Remember, we specified OfflineIMAP to use Maildir format, so when asked by sup-config what source you require, you must select “2. maildir directory”. The you must enter the full path as specified in the location of localfolders in the OfflineIMAP config. You can make your own minds up about the following config options.

That’s pretty much it. You will want to sync your mailbox now, and once done so run sup again. This time you should see all your emails. If now, again, look at your config options and the wiki.

Sending Email: MSMTP

Reading emails is great, but one day you may want to actually send one yourself. When I tried to do this I was greeted with an error – I didn’t have sendmail. After some browsing around, it was clear that the easiest way to send email was via the MSMTP package.

Again, installation is effortless on Ubuntu:

sudo apt-get install msmtp

Configuration was slightly more tricky and I had to play around a lot before it worked as expected.

My SMTP server is a normal hosted package running Exim, but this doesn’t really matter. The key was that I have to authenticate myself to send. First, create a config file in your home directory .msmtprc and fill in your configuration details. Mine are as below, but

#Set default values for all following accounts.
logfile ~/Mail/.msmtp.log
account foobar
host mail.bar.co.uk
from foo@bar.co.uk
auth on
tls on
user foo
password raboof
# Set a default account
account default : foobar

I don’t know if the “tls on” option is needed for my particular config, but it seems to work, so who am I to complain?!

When testing your config, a good plan is to run MSMTP in the same way as Sup is expecting to. My test command was:

msmtp  --account=foobar -t < test.mail

The contents of test.mail were very simple:

To: test@bar.co.uk
From: foo@bar.co.uk
Subject: Test from command line
Hello, this is a test

I had to play around a lot with the config before it worked for me, but I found the above the quickest way to test it without having to enter your email again and again.

Once all working, you need to edit the Sup config file to use MSMTP. The config file can be located at ~/.sup/config.yaml and in your :accounts: section edit the :sendmail: line to read

:sendmail: msmtp --account=foobar -t

Now, test sending an email from Sup and hopefully it’ll work! Again, if not requires lots of playing about and testing different combinations, but if you can send from the command line, you should be able to send from Sup.

And that’s it!

Phew, it was a long effort, but hopefully well worth it. Please let me know if it was!

More Sup posts

  • Pingback: Rob Searles » Sup Mail Client is Saving my life

  • adam

    nice! by the way, sup isn’t a “rails package”. its a ruby program. has nothing to do with rails.

  • adam

    nice! by the way, sup isn't a “rails package”. its a ruby program. has nothing to do with rails.

  • http://github.com/remogatto remogatto

    Nice post, thanks for sharing. Please note that sup is not a Rails package. It’s just a regular ruby program.

  • http://github.com/remogatto remogatto

    Nice post, thanks for sharing. Please note that sup is not a Rails package. It's just a regular ruby program.

  • Pingback: » Sup Crash! Index locked then Terminates. Easy Fix