Email with Mutt, IMAP and SSMTP

I have written about my previous experience with mutt, and I shared my Mutt cheatsheet. Today, I started using Mutt again for a new account. Last time, I used fetchmail to pull all my email down locally, this time, I am using an externally hosted email accessed through IMAP.

The machine runs Gentoo, so I ran:

cat mail-client/mutt ssl imap pop > /etc/portage/package.use emerge mutt

On Ubuntu, you can use:

sudo apt-get install mutt

As well as Mutt, you also need a way to send email from your system. Traditionally that would mean running a full SMTP server.

However, if you using a domestic Internet connection where the IP Address is dynamic, or if you are doing everything from a laptop that moves around, then using a full SMTP server is possibly not the best plan.

So in these cases, you can use a simple transfer agent that just forwards outgoing mail to a full SMTP server hosted elsewhere, such as one provided by your ISP, University or whatever.

There are several of these, including nbsmtp, esmtp and ssmtp. I have used nbsmtp before but this time I am using ssmtp since it was on my system already.

If you don't have it already, you can install it with, on Gentoo:

emerge ssmtp

On Ubuntu:

sudo apt-get install ssmtp

In order to be allowed to send email, you need to add yourself to the ssmtp group:

sudo usermod -a -G ssmtp username

Or the more modern approach:

sudo adduser username ssmtp

Now we need to edit the ssmtp configuration:

sudo emacs /etc/ssmtp/ssmtp.conf

This depends a little on your set up, I used the following:

root=Your email address
mailhub=Your SMTP Server
rewriteDomain=Your email domain
AuthUser=Your username at the SMTP server (e.g. your email address)
AuthPass=Your password at the SMTP server
UseTLS=YES
UseSTARTTLS=YES
FromLineOverride=YES

If all is well, then we can test the outgoing mail by sending an email to somewhere:

echo "hello world" | /usr/sbin/ssmtp someemail@provider.com

If you don't get the email, then your settings are not correct.

Now we need to configure mutt by editing the personal configuration file:

emacs ~/.muttrc

I put in the following to retrieve the email via IMAP:

set folder="imaps/username@server.com"
set spoolfile="imaps/username@server.com/INBOX"
set imap_pass="password"
set sendmail="/usr/sbin/ssmtp"
set from="Your Name <email@address.net>;"

Now I had functioning email. Mutt has completely configurable colours, so theming Mutt is a big part of it.

For now, I just grabbed the scheme from Andy Smith's blog

I hope that is useful to someone. I would be interested in you handle your email. What do you like and dislike about your email setup?

If you are a Mutt user, please let us all know how you find it and feel free to give us tips and tricks that you have learned along the way.

One thought on “Email with Mutt, IMAP and SSMTP”

  1. <p>I propose you use /bin/echo instead of /bin/cat and append-pipe (&gt;&gt;) to package.use.</p>

How about Global Thermonuclear War? Wouldn't you prefer a good game of chess? Powered by zpress