Introduction
in this tutorial, we will guide you through the process of configuring Postfix to relay emails through Amazon Simple Email Service (SES) using the Simple Mail Transfer Protocol (SMTP). This setup enables your server to send emails via Amazon SES.
Prerequisites
- Postfix installed and configured on your server
- Amazon SES account with SMTP credentials
- Basic knowledge of Linux commands and Postfix configuration
Step-by-Step Configuration
Step 1: Create Directory and File for SMTP Credentials
Create a new directory to store your SMTP credentials:
mkdir /etc/postfix/password/
Create a text file aws inside the newly created directory:
nano /etc/postfix/password/aws
Insert the following content, replacing Your-Username and YourPassword with your Amazon SES SMTP credentials:
#smtp.isp.com username:password
email-smtp.us-east-1.amazonaws.com Your-Username:YourPassword
Save and close the file.
Step 2: Secure SMTP Credentials File
Set ownership and permissions for the aws file:
chown root:root aws
chmod 0600 aws
This ensures only the root user can read and write to the file.
Step 3: Create Hash Database
Create a hash database for the aws file:
postmap hash:aws
This command creates a hashed version of the aws file, which Postfix uses for lookup.
Step 4: Configure Postfix
Edit the Postfix main configuration file:
nano /etc/postfix/main.cf
Add or modify the following lines:
relayhost = email-smtp.us-east-1.amazonaws.com
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/password/aws
smtp_sasl_security_options =
Save and close the file.
Step 5: Reload Postfix Service
Reload the Postfix service to apply changes:
systemctl reload postfix.service
Verification
IN EFA goto option 7, Mail Settings. Then 2, Outbound Smarthost then add AWS SMTP host there.
Also allow your local mail server (IP ADD) in option 1, Outbound mail Relay, so EFA will allow your local mail server to send emails via AWS smart host.
Test your setup by sending an email using the mail command or your preferred email client.
Troubleshooting Tips
- Check Postfix logs for errors: tail -f /var/log/maillog
- Verify Amazon SES SMTP credentials
- Ensure correct file permissions and ownership
Conclusion
By following these steps, you have successfully configured Postfix to relay emails through Amazon SES using SMTP. This setup enhances email delivery and provides a scalable solution for your email needs.
Additional Resources
- Amazon SES Documentation: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/
- Postfix Documentation: http://www.postfix.org/documentation.html
Comments
Post a Comment