Using postfix send email through AWS SES in Google Cloud Compute

To send email using AWS SES in Google Cloud Compute:

  1. Install Postfix (default installed) when you create GCE instance. We need install package:

#yum install cyrus-sasl-plain

2. Add lines to /etc/postfix/main.cf

#vi /etc/postfix/main.cf

relayhost = [email-smtp.us-west-2.amazonaws.com]:2587
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt

3. Create file /etc/postfix/sasl_passwd

#vi /etc/postfix/sasl_password

[email-smtp.us-west-2.amazonaws.com]:2587 SES_USERNAME:SES_PASSWORD

4. Postmap hash sasl_password file

#postmap hash:/etc/postfix/sasl_passwd

5. Secure Postfix

#rm -rf /etc/postfix/sasl_passwd

#chmod 600 /etc/postfix/sasl_passwd.db

6. Restart Postfix server and test send email through SES

#service postfix restart

#sendmail -f from@example.com to@example.com

FROM: from@example.com

Subject: TEST

TEST EMAIL FROM GCE USING AWS SES.

.

7. Check log at /var/log/maillog