35
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

EC2上のPostfixからSES経由でメール送信

Last updated at Posted at 2014-09-01

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に下記を追記
/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を作成
/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
35
37
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
35
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?