EC2のZabbixからアラートメールを送る場合、スクリプトではなく、ローカルのPostfixから送信する
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html
Update : SES Endpointの25番ポートに接続すると、Connection Timeoutが多発し、配送が遅延するので、587番ポートに変更
http://stackoverflow.com/questions/11194080/amazon-ec2-ses-smtp-timeout
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-issues.html
You are sending to Amazon SES from an Amazon EC2 instance via port 25 and you cannot reach your Amazon SES sending limits or you are receiving time outs—Amazon EC2 imposes default sending limits on email sent via port 25 and throttles outbound connections if you attempt to exceed those limits. To remove these limits, submit a Request to Remove Email Sending Limitations. You can also connect to Amazon SES via port 465 or port 587, neither of which is throttled.
- PostfixをインストールしてSendmailをアンインストール
$ sudo yum install postfix
$ sudo yum remove sendmail
$ chkconfig postfix on
- Sendmailを残しておく場合
$ alternatives --set mta /usr/sbin/sendmail.postfix
- /etc/postfix/main.cfに下記を追記
relayhost = email-smtp.us-east-1.amazonaws.com:587
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
- /etc/postfix/sasl_passwdを作成
email-smtp.us-east-1.amazonaws.com:587 USERNAME:PASSWORD
- パスワードDB生成
$ sudo postmap hash:/etc/postfix/sasl_passwd
$ sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
$ sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
- Postfix再起動
$ sudo /etc/init.d/postfix restart