Chris Boyle

Random bits to remember, mostly about Gentoo and Ruby.

sSMTP and Amazon SES

I have always been too lazy to setup a working mta just to get cron or other system emails sent. Amazon’s Simple Email Service (SES) recently added SMTP server support which will work nicely with sSMTP, which is installed as the default mta on Gentoo. It isn’t free but if you’re in Amazon’s ecosystem the extra ten cents for a few hundred emails is negligible.

Setup is very similar to using gMail’s servers. Enable SMTP support for SES. This can easily be done in the AWS management console. You also need production access unless you want to verify every email that will be sending or receiving mail. You do still need one verified email for the sender. I use hostname@bbck.net for each machine. If you are not in the US-east region the server will need to be changed then what is below.

/etc/ssmtp/ssmtp.conf
1
2
3
4
5
6
7
8
9
10
11
12
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
mailhub=email-smtp.us-east-1.amazonaws.com:465
AuthUser=SMTPUSER
AuthPass=SMTPPASS

# Where will the mail seem to come from?
rewriteDomain=example.com

# Use SSL/TLS to send secure messages to server.
UseTLS=YES

You will also need an alias for each user who sends mail.

/etc/ssmtp/revaliases
1
2
3
4
5
6
7
8
# sSMTP aliases
# 
# Format:       local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:verifiedemail@example.com:email-smtp.us-east-1.amazonaws.com:465
user:verifiedemail@example.com:email-smtp.us-east-1.amazonaws.com:465

You should be up and running. One caveat is the full recipient email needs to be specified. Vixie-con only would only attempt to send to root with no domain. Setting MAILTO=root@example.com in any cron scripts should fix that, but I would like to find some way to append the domain if it is missing automatically.