LoginSignup
19
17

More than 5 years have passed since last update.

EC2のpostfixでSESにリレーしてメールを送る設定

Last updated at Posted at 2014-10-21

EC2からメールを送ると結構すぐにブロックされるらしいので、メールの送信をSES経由で行うようにする。
SESは設定済としてPostfixのリレー設定方法。

SMTP認証に必要なパッケージをインストール

yum -y install cyrus-sasl-plain cyrus-sasl-md5

/etc/postfix/main.cf に以下のような記述を追加。
relayhostはSESのSMTPエンドポイント

relayhost = email-smtp.us-east-1.amazonaws.com:25
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt

# fix for CVE-2014-3556 (POODLE)
smtpd_tls_mandatory_protocols=!SSLv2,!SSLv3
smtp_tls_mandatory_protocols=!SSLv2,!SSLv3
smtpd_tls_protocols=!SSLv2,!SSLv3
smtp_tls_protocols=!SSLv2,!SSLv3

/etc/postfix/sasl_passwdを作成

echo "email-smtp.us-east-1.amazonaws.com:25 アクセスキー:シークレットキー" > /etc/postfix/sasl_password

ハッシュ化

postmap hash:/etc/postfix/sasl_password 

再起動

/etc/init.d/postfix restart

確認

mail hogehoge@hogehoge.com

/var/log/maillogの確認 & 実際にメールが届いたかを確認。

19
17
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
19
17