I know this question is a year old but why use the script when Postfix handles relaying through SES just fine using SMTP.
You can either setup your relayhost
if the only email being sent is from a verified sender or verified domain or you can use sender_dependent_relayhost_maps
to relay only those domains and senders verified.
In either case you would start by setting up the SASL password for SMTP AUTH. I use /etc/postfix/sasl_password
and it should follow the format of:
email-smtp.us-east-1.amazonaws.com SES-USER:SES-USER-PASSWORD
Update to use the SMTP host from your AWS SES Console and the appropriate SES SMTP user credentials. Next you need to configure the SMTP SASL client settings in /etc/postfix/main.cf
by adding the following:
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
smtp_sasl_security_options=noanonymous
smtp_sasl_mechanism_filter = login
Now run postmap /etc/postfix/sasl_password
and that is all set. Now you have to decide if you're relaying everything or just verified senders/domains. If relaying everything then simply add the following to your main.cf
:
relayhost = email-smtp.us-east-1.amazonaws.com
On the other hand if you only want to send verified senders/domains then add the following to your main.cf
instead:
sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_maps
Then in /etc/postfix/relayhost_maps
add your verified senders/domains following the format of:
[email protected] email-smtp.us-east-1.amazonaws.com
@example.net email-smtp.us-east-1.amazonaws.com
Run that file through postmap /etc/postfix/relayhost_maps
and do a postfix reload
and you should be sending emails through SES.