How to build a Docker image with sSMTP and Amazon SES
What is sSMTP?
SSMTP is a simple MTA (Mail Transfer Agent) that can be used to send email from a command line. It is not a full-fledged MTA like Postfix or Sendmail, but it is good enough for sending email notifications from your Docker containers.
What is Amazon SES (Simple Email Service)?
Amazon SES is a cloud-based email sending service that allows you to send email without having to maintain your own email servers.
Configuring sSMTP with Amazon SES
To use sSMTP with Amazon SMS, you need to configure it to use Amazon’s SMTP server.
- Log in to your AWS account.
- Sign up for the Amazon SES service.
- Pre-verify any email addresses you intend to use for testing on Amazon SES. You must verify both your sender and recipient email addresses, or your message will be rejected.
- Once you’ve confirmed the basic email service is working, request access to Amazon SES for sending emails by moving out of the sandbox.
Use the Amazon SES console to create new Amazon SES SMTP credentials. Then you have to put credentials into your sSMTP configuration file.
Let’s create a ssmtp.conf
file with the following content:
Last line in ssmtp.conf
config need to be keep empty! Let’s test our config in Docker.
Prepare Dockerfile
To add sSMTP to your Docker container, you can use the following Dockerfile
:
There are only sSMTP
and mailx
packages inside the image. Command COPY
will copy the ssmtp.conf
file to the /etc/ssmtp/ssmtp.conf
path.
Build the image with the following command:
You can test the image and run it with interactive mode:
Amazon provides a mailbox simulator:
but you can use any email address, for example, with sendmail
:
Check your email. Congratulations! You have successfully configured sSMTP with Amazon SES in Docker.