質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

1回答

5285閲覧

AWSのSES経由のメールが送られない。EC2のmailコマンド。

lin.ming

総合スコア50

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2020/03/08 10:13

編集2020/03/10 08:22

##やりたいこと
ec2上のmailコマンドで、SES経由でメールをlinming@gmail.comに送りたい。
##やったこと
###AWSのSESの設定
####SESでのドメインの確認
AWSのドキュメントにしたがってlinming.example.netのドメイン認証をしました。
EasyDKIMも同時に行いました。
#####SESのDomainsタブでは、

  • Domain Identities は linming.example.net
  • Verification Status は verified
  • DKIM Status は verified
  • Enabled for Sending は Yes

です。
#####SESのEmail Addressesタブでは

をverifiedにしました。
#####SESのReputation Dashboardタブでは

  • Account status:HEALTHY

です。
###Postfixの設定
https://docs.aws.amazon.com/ja_jp/ses/latest/DeveloperGuide/postfix.html
にしたがって設定しました。
##試してみたこと
EC2にSSHでログインして

df -h | mail -s 'test mail' linming@gmail.com

を実行しました。
メールは送られてきませんでした。
##maillog

Mar 8 19:02:31 linming postfix/pickup[24279]: 11E748B6AA: uid=1001 from=<linming> Mar 8 19:02:31 linming postfix/cleanup[24619]: 11E748B6AA: message-id=<20200308100231.11E748B6AA@linming.example.net> Mar 8 19:02:31 linming postfix/qmgr[23869]: 11E748B6AA: from=<linming@linming.example.net>, size=810, nrcpt=1 (queue active) Mar 8 19:02:32 linming postfix/smtp[24621]: 11E748B6AA: to=<linming@gmail.com>, relay=email-smtp.us-west-2.amazonaws.com[52.41.197.26]:587, delay=1, delays=0.01/0.01/0.87/0.1, dsn=5.0.0, status=bounced (host email-smtp.us-west-2.amazonaws.com[52.41.197.26] said: 530 Authentication required (in reply to MAIL FROM command)) Mar 8 19:02:32 linming postfix/cleanup[24619]: 42EA28B6CE: message-id=<20200308100232.42EA28B6CE@linming.example.net> Mar 8 19:02:32 linming postfix/qmgr[23869]: 42EA28B6CE: from=<>, size=2836, nrcpt=1 (queue active) Mar 8 19:02:32 linming postfix/bounce[24622]: 11E748B6AA: sender non-delivery notification: 42EA28B6CE Mar 8 19:02:32 linming postfix/qmgr[23869]: 11E748B6AA: removed Mar 8 19:02:32 linming postfix/local[24623]: 42EA28B6CE: to=<linming@linming.example.net>, relay=local, delay=0.01, delays=0/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox) Mar 8 19:02:32 linming postfix/cleanup[24619]: 455738B6AC: message-id=<20200308100232.42EA28B6CE@linming.example.net> Mar 8 19:02:32 linming postfix/qmgr[23869]: 455738B6AC: from=<>, size=2983, nrcpt=1 (queue active) Mar 8 19:02:32 yumeka postfix/local[24623]: 42EA28B6CE: to=<linming@linming.example.net>, relay=local, delay=0.01, delays=0/0.01/0/0, dsn=2.0.0, status=sent (forwarded as 455738B6AC) Mar 8 19:02:32 linming postfix/qmgr[23869]: 42EA28B6CE: removed

##間違っていると考えていること
maillogで、

status=bounced (host email-smtp.us-west-2.amazonaws.com[52.41.197.26] said: 530 Authentication required (in reply to MAIL FROM command))

と出力されていることから、認証情報をmailコマンド実行時に与えなければいけないと考えています。
SESの設定で、上記以外のことはしていません。
やり忘れたことがありましたら、ご教示ください。

##追記
postfix の main.cf の smtp_sasl_password_maps は、

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

です。

# postmap hash:/etc/postfix/sasl_passwd

を実行しました。
sasl_passwd の内容は、

[email-smtp.us-east-1.amazonaws.com]:587 XXXXXXXXXXJKWNEYVP5TEB:XXXXXXXX/uUhjOrQTZptzglZquGS+iVnMom4h3MLWf

です。(2020-3-10 17:22修正)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

認証情報は mail コマンドではなく、postfix の smtp_sasl_password_maps で指定したファイルに設定します。


(2020/03/10 17:15) 追記
マップファイルの書式が違います。
SES 開発者ガイドにあるように、左辺に relayhost の設定値、右辺に ユーザー名:平文パスワード を記述します。

ユーザー名、パスワードは別途取得する必要があるようです。

Amazon SES SMTP 認証情報を取得する

投稿2020/03/09 11:23

編集2020/03/10 08:15
TaichiYanagiya

総合スコア12141

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

lin.ming

2020/03/10 02:22

ご回答ありがとうございます。 sasl_password の件、質問に追記しました。 ご覧いただけるとありがたいです。
lin.ming

2020/03/10 08:24

質問を一部修正しました。 左辺は [email-smtp.us-east-1.amazonaws.com]:587 右辺は あげられたリンクで取得した ユーザ名:パスワード の認識で合っていますか?
TaichiYanagiya

2020/03/10 11:40

認証は通ったのですね。 bounced のときの Postfix のログ、および、SES 側のログ、通知などは?
lin.ming

2020/03/10 21:45

bounce の時の Postfix のログは質問文に書きました。 SES 側のログは、「1件も送ってないよ」です。
TaichiYanagiya

2020/03/10 21:52

認証失敗→bounce は変わっていないのですね。 じゃあ、ユーザー/パスワードが違うか、relayhost とマップファイルが一致していないか、そもそも relayhost 先が違う(リージョンが違う、など)かではないでしょうか。
lin.ming

2020/03/11 01:05

relayhost 先が違っていました。 私が作ったリージョンは us-east1 SES のドキュメンでは us-west2 でした。 us-east1 に変更したら無事メールが配送されました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問