SES(メール配信サービス)編~Simple Email Service パート④~

こんにちは! JQです。

前回は『 SES(メール配信サービス)編~Simple Email Service パート③~ 』ということで、SESでDKIMの設定をしてみました。

今回は『SES(メール配信サービス)編~Simple Email Service パート④~』と題して、PostfixからSESへリレー設定してみたいと思います。

Postfix設定

8.Postfix設定

必要な物をインストールします。

1# yum -y install postfix mailx cyrus-sasl-plain cyrus-sasl-md523# chkconfig postfix on45# /etc/rc.d/init.d/sendmail stop67Shutting down sm-client:                                   [  OK  ]8Shutting down sendmail:                                    [  OK  ]910# chkconfig sendmail off
1# alternatives --config mta
1There are 2 programs which provide 'mta'.
1Selection    Command2-----------------------------------------------3*+ 1           /usr/sbin/sendmail.sendmail4   2           /usr/sbin/sendmail.postfix
1Enter to keep the current selection[+], or type selection number: 2

Postfixの設定に下記を追記します。

1# vim /etc/postfix/main.cf2relayhost = email-smtp.us-east-1.amazonaws.com:5873smtp_sasl_auth_enable = yes4smtp_sasl_password_maps = hash:/etc/postfix/ses_sasl5smtp_sasl_security_options = noanonymous6smtp_sasl_mechanism_filter = plain7smtp_use_tls = yes8smtp_tls_security_level = encrypt9smtp_tls_note_starttls_offer = yes10smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt

SESに接続するための情報を設定します。

1# vim /etc/postfix/ses_sasl2email-smtp.us-east-1.amazonaws.com:587 [Smtp Username]:[Smtp Password]

次のコマンドで反映させます。

1# postmap /etc/postfix/ses_sasl

Postfixを起動します。

1# /etc/rc.d/init.d/postfix start2Starting postfix:                                          [  OK  ]

9.テスト送信

それでは実際に送ってみましょう!

メールコマンドで送信してみます。

1# echo "test" |mail -s "test" -r [FromAddress] [ToAddress]

ログを確認してみればSESからRelayされているのが分かります!

1# tail /var/log/maillog23Jan 22 09:26:51 ip-10-239-48-164 postfix/qmgr[2699]: 1347462804: from=< FromAddress >, size=486, nrcpt=1 (queue active)4Jan 22 09:26:51 ip-10-239-48-164 postfix/smtp[2719]: 1347462804: to=<ToAddress>, relay=email-smtp.us-east-1.amazonaws.com[54.243.69.182]:587, delay=1843, delays=1843/0.06/0.11/0.16, dsn=2.0.0, status=sent (250 Ok 00000143b946086a-0bd69efa-c627-4ccd-a596-72a101dd8dd2-000000)

いかがでしたでしょうか?

次回もお楽しみに!!!

この記事を書いた人

aws-recipe-user