ses の変更点   

  • 追加された行はこの色です。
  • 削除された行はこの色です。
  • ses へ行く。

#author("2021-01-22T05:09:29+00:00","default:pentacle","pentacle")
aws ses で postfix からメールを送る方法

- aws centos7
- postfix

* introduction [#i8bf11fb]
- AWS EC2 インスタンスにpostfix を入れても外部には直でメールを出せない(1,2通は出せても制限がかかる)
- SES という amazon の smtp を経由する必要がある
- postfix と連携できるため、既存のアプリをそのまま移行できる 

* AWS側の設定 [#j79f48d9]

 下記にアクセス
 https://ap-northeast-1.console.aws.amazon.com/ses/home?region=ap-northeast-1#

*** 制限解除 [#uf741a6c]
 【左ペイン】→【Sending Statistics】

 Server Name をメモる:email-smtp.ap-northeast-1.amazonaws.com ※1

 Production Access が Sandbox の場合は 【Edit your account details 】をクリック
 適切に項目を埋める
 zabbix notify mail 等でOK

*** domain の所有確認 [#qcb90e81]
 左ペイン 【Domains】
 【Verify a New Domain」
 ドメイン名を入れてDNS情報を入れる。
 同じアカウントで R53 でDNS管理しているならそのまま入れてくれる
 ※ MX レコードにはチェックを入れるとメールがとどかなくなるので要れないこと

*** AMIアカウントの作成 [#r0f90db2]

 左ペイン 【SMTP Settings】 → 【Create My SMTP Credentials】
 【作成】
 認証情報をメモる
 SMTP ユーザー名: ※2
 SMTP パスワード: ※3
 

* install [#d589bca1]

 sudo yum -y install postfix cyrus-sasl-plain


*** postfix の設定 [#fc1773dd]
#pre{{

sudo postconf -e "relayhost = [email-smtp.ap-northeast-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"

}}

*** 送信元アドレスの設定 [#l6177660]

 sudo postconf -e "mynetworks = 192.168.0.0/24, localhost, 127.0.0.1"

*** SASL 情報 [#c3dec1ad]
''/etc/postfix/sasl_passwd''

 [email-smtp.ap-northeast-1.amazonaws.com]:587 【※2】:【※3】


 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
 sudo systemctl enable postfix.service
 sudo systemctl restart postfix


*** メール送信テスト [#pa2578cb]
ドメイン認証しているアドレスからでないとダメ

 sendmail -f 【送信元アドレス】 【送信元アドレス】

 From: 【送信元アドレス】
 Subject: test mail
 test
 .