Configure Amazon SES with Exim
I have been working on different MTAs since the last couple of years. This time, the Exim4 use-case which I encountered was to sends emails using premium Email Service Provider.
Use-case: We were supposed to send thousands of emails like auto-reply emails or newsletters from our dedicated server(Ec2 machines) inside the private subnet.
I chose to use Amazon SES, a platform which provides transactional and cost-effective email service using your own email addresses and domains. Click on link to learn more about AWS SES.
Reasons why I chose SES:
- Reliability
- Cost
- Account Security
- Deliverability
- Scalability
Exim4 is a general purpose mail package that is highly configurable and flexible. Refer this link to know more about Exim.
Now, Let us configure the Exim4 with following steps:
- Install the package
apt-get install exim4
- Configure the Exim
sudo dpkg-reconfigure exim4-configMail Server Configuration 1) Mail configuration type as “internet site; mail is sent and received directly using SMTP” 2) Enter the system’s FQDN in the mail name configuration screen. 3) Enter 127.0.0.1 for listen address 4) and rest of the steps, take the default value.
- Confirm if Exim process has started on port 25 using below command.
sudo netstat -ntpl
Configuration of the AWS SES with Exim4 includes following steps:
- Verifying the domain or email address with SES. For more details, follow this link.
- Create and download the SMTP credentials from AWS SES console. For more details follow this link.
- Now make the following changes in /etc/exim/exim.conf
send_via_ses: driver = manualroute domains = ! +local_domains transport = ses_smtp route_list = * email-smtp.us-east-1.amazonaws.com2) In the transports section, add these following lines:
ses_smtp: driver = smtp port = 587 hosts_require_auth = $host_address hosts_require_tls = $host_address3) In the authenticator section, add these following lines:
ses_login: driver = plaintext public_name = LOGIN client_send = : xxUSER-NAME-xxxx : xxxxxxxPASSWORDxxxxxxNote: Use SMTP username and password which were obtained in CSV file, not your AWS access key ID and secret access key. 4) Change existing line “public_name = LOGIN” to following:
public_name = OLD_LOGIN
- Restart the Exim service.
sudo service exim4 restart
- Now, try sending a mail.
echo AWS-SES-MAIL | mail -r verfiyed-mail-address@from-ses-console.com -s TEST your-mail-address@example.com
- For further debugging, please refer the log file.
tailf /var/log/exim4/mainlog
That’s all in this blog. If you face any issues don’t forget to share your feedback down below.