Using SSMTP with Fastmail

written on Sunday, January 26, 2014 by

A few months ago, I switched from Gmail to Fastmail. So far I've been quite happy about it, they provide great service and you can use your own domain for 40$ per year. As a bonus, the company is owned by the employees, always a good thing.

If you want to be able to send emails from your Fastmail account via commandline, the easiest thing is to install SSMTP, a simple send-only sendmail emulator.


First, you should create a separate password in your account settings ("Advanced" → "Alternative Logins"). Choose "Regular" as login type and choose a password (ideally very long but without any special characters in it, to avoid parsing problems).

Then use the following configuration for your /etc/ssmtp/ssmtp.conf file. The configuration assumes that is your Fastmail account login and is your primary email address. If you don't use a custom domain, just use your regular Fastmail address in both places.

# /etc/ssmtp.conf -- a config file for sSMTP sendmail.

# The user that gets all mail for userids less than 1000. If blank, address
# rewriting is disabled.

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named

# TLS Config

# Where will the mail seem to come from?

# The full hostname

# Username and password

Make sure to lock down the permissions of the config file, as it contains your password in plaintext:

sudo chown root:mail /etc/ssmtp/ssmtp.conf
sudo chmod 640 /etc/ssmtp/ssmtp.conf

Add yourself to the mail group if you haven't already:

sudo usermod -a -G mail <local-username>


Possibly you have to logout and login again for the group permissions to work properly. You can now test whether sending email works:

echo "Testing SSMTP." | mail -s 'SSMTP Test'

This entry was tagged linux and mail