Taking back email – Part 5: msmtp

Recently, I decided to revamp my email setup. I don’t really love email, but it’s such an important method of communication that I needed to get it under control. I’m going to put together a several-post guide explaining my reasoning, technical details, and my new email process.

Other posts in this series (all will be linked here as the posts go up:)

Intro

alot to read and compose email, and khard for integrating an address book

msmtp is a utility for sending email through an SMTP server. After you compose an email using alot, msmtp will handle sending it out. You’ll want msmtp installed on the machine you are using to compose email – so I have it installed on my two workstations rather than on a centralized server.

(In practice, I have it on the server as well in case I ever need to ssh in and write an email, but I haven’t used that option yet).

Installing msmtp

In Arch Linux, msmtp is in the standard repositories. Install it like so:

sudo pacman -S msmtp

Configuration

I should mention that the Arch Linux wiki is really helpful for just about everything, and msmtp is no exception. They have a great article here.

After installing, copy the example configuration into your home directory and start editing!

cp /usr/share/doc/msmtp/msmtp-user.example ~/.msmtprc
vim ~/.msmtprc

Overall, editing this file is pretty easy – just follow the example. Your SMTP server may require some specific settings, so play with it a bit. See some testing tips in the next section of this post.

Here’s an example of one of my accounts, with some sensitive information edited:

account ajy
host smtp.example.com
port 587 # Alternatively, try port 465 if this one doesn't work
from aaron@example.com
user aaron@example.com
# tls and password - you should decide how you will handle these

For the TLS certificate and password settings, follow the examples in the config file based on what strategy you will use.

Set a default account:

account default : ajy # Choose an account name as specified above

Testing your configuration

To test your SMTP configuration, I recommend creating an email in a text file: vim test-mail.txt with something like the following content: