お名前.comのDNSサーバに、AWSのElastic IPをAレコードで登録、SPF TXTレコードに追加。
a.b.c.d=AWSのElastic IP
【A レコード】 mailaws A a.b.c.d
【TXT レコード 変更前】 m2env.net text = "v=spf1 include:spf.protection.outlook.com ~all" 【TXT レコード 変更後】 m2env.net text = "v=spf1 +ip4:a.b.c.d/32 include:spf.protection.outlook.com ~all"
メールを送信したけど、まだエラーになります。。。AWSの申請をしてみないとかな。
[ec2-user@ip-172-31-101-122 ~]$ telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 ip-172-31-101-122.us-east-2.compute.internal ESMTP Postfix HELO test.com 250 ip-172-31-101-122.us-east-2.compute.internal MAIL FROM: hoge@hoge.com 250 2.1.0 Ok RCPT TO: hoge@gmail.com 250 2.1.5 Ok DATA 354 End data with <CR><LF>.<CR><LF> Subject: TEST Mail TEST MAIL. . 250 2.0.0 Ok: queued as 7EA0D5C12B QUIT 221 2.0.0 Bye Connection closed by foreign host. [ec2-user@ip-172-31-101-122 ~]$
[ec2-user@ip-172-31-101-122 ~]$ sudo tail -f /var/log/maillog Dec 12 09:08:58 ip-172-31-101-122 postfix/smtp[5305]: connect to alt1.gmail-smtp-in.l.google.com[2607:f8b0:400c:c08::1a]:25: Network is unreachable Dec 12 09:09:28 ip-172-31-101-122 postfix/smtp[5305]: connect to alt2.gmail-smtp-in.l.google.com[64.233.186.27]:25: Connection timed out Dec 12 09:09:28 ip-172-31-101-122 postfix/smtp[5305]: 45C495C153: to=<hoge@gmail.com>, relay=none, delay=29897, delays=29807/0.01/90/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[64.233.186.27]:25: Connection timed out) Dec 12 09:19:02 ip-172-31-101-122 postfix/smtpd[5454]: connect from localhost[127.0.0.1] Dec 12 09:19:35 ip-172-31-101-122 postfix/smtpd[5454]: 7EA0D5C12B: client=localhost[127.0.0.1] Dec 12 09:19:49 ip-172-31-101-122 postfix/cleanup[5458]: 7EA0D5C12B: message-id=<20211212091935.7EA0D5C12B@ip-172-31-101-122.us-east-2.compute.internal> Dec 12 09:19:49 ip-172-31-101-122 postfix/qmgr[2971]: 7EA0D5C12B: from=<hoge@hoge.com>, size=408, nrcpt=1 (queue active) Dec 12 09:19:51 ip-172-31-101-122 postfix/smtpd[5454]: disconnect from localhost[127.0.0.1] Dec 12 09:20:19 ip-172-31-101-122 postfix/smtp[5459]: connect to gmail-smtp-in.l.google.com[142.251.4.27]:25: Connection timed out Dec 12 09:20:19 ip-172-31-101-122 postfix/smtp[5459]: connect to gmail-smtp-in.l.google.com[2607:f8b0:4023:1407::1a]:25: Network is unreachable Dec 12 09:20:49 ip-172-31-101-122 postfix/smtp[5459]: connect to alt1.gmail-smtp-in.l.google.com[108.177.12.27]:25: Connection timed out Dec 12 09:20:49 ip-172-31-101-122 postfix/smtp[5459]: connect to alt1.gmail-smtp-in.l.google.com[2607:f8b0:400c:c08::1b]:25: Network is unreachable Dec 12 09:20:49 ip-172-31-101-122 postfix/smtp[5459]: connect to alt2.gmail-smtp-in.l.google.com[2800:3f0:4003:c00::1b]:25: Network is unreachable Dec 12 09:20:49 ip-172-31-101-122 postfix/smtp[5459]: 7EA0D5C12B: to=<hoge@hoge.https://aws.amazon.com/jp/premiumsupport/knowledge-center/ec2-port-25-throttle/com>, relay=none, delay=83, delays=23/0.01/60/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[2800:3f0:4003:c00::1b]:25: Network is unreachable) ^C
Elastic IPの割り振り、DNSの登録は間違えていないと思いますので、AWSへの申請を出してみようと思います。
Amazon EC2 インスタンスまたは AWS Lambda 関数のポート 25 に対する制限を解除するにはどうすればよいですか?
続く。