ec2ホストからメール飛ばしたい場面がある。

普通のlinuxからやったら、自分でもローカルlinuxとgoogle cloudのlinuxで飛ばしてる。

利用者様にサーバ提供するとき「ポート25のsmtp使いたい」って言われることがたまにいるんやけど、awsではsmtpはそのままは使えんから申請出す。

awsコンソールにログイン後、サポートの申請する。

普段の申請

使ってるメールサーバで受け取れるアドレスと依頼文書を入力する。

aws-smtp25

グローバル窓口やから本文は英文で作らなアカンし、生成AI使って「awsでポート25解放する利用申請文章を英語で作って」でもええんやけど、いっつもこのへん使ってる。

1
2
3
4
5
6
7
8
Removal of E-mail sending limit.
・Used as a notification email from the internal system. ⭐️内部のシステムで使ってまーす
・The destination is limited to the e-mail address registered in the address book. ⭐️アドレス帳に入ってる決まったメールアドレスに送りまーす
・Use MTA and take necessary measures such as SPF / DKIM. ⭐️MTA使うのと、認証もちゃんとやりまーす
・EC2 that wants to allow port 25 as outbound Does not own an Elastic IP Address. ⭐️ポート25使いたいでーす
・Do not use reverse DNS records. ⭐️逆引きdnsいりませーん
・Go out to the internet using your on-premises environment via DirectConnect. ⭐️directconnect使ってオンプレ経由でインターネットにメール飛ばしまーす。
・10 or more e-mail will be send by crond everyday morning from ec2(i-xxxxxxxxxxxx). ⭐️ec2ホストからcrond使って毎朝10本ぐらいメール飛ばしまーす

申請したメールアドレスに2~3日程度でawsからメールが戻ってくる。もちろん英文。

利用者に飛んでくるから、転送してもらうよう頼んどく。

こんな感じで承認された内容が戻ってきたら25番でsmtp使えるようになる。

1
2
3
4
5
6
Hello,

We approved your request for the removal of the EC2 email sending limitations 
on your Amazon Web Services account for the following regions [ap-northeast-1]! 
If you requested removal of email sending limits on any other Amazon Elastic IPs, 
they've also been removed.

複数のリージョン使ってたら、リージョンごとに申請必要やったはず。

メール飛ぶか試す

ec2-linuxホストやったら mailコマンド 使ったら飛ばす確認できる。

ec2-windowsホストやったら、powershellでメール飛ばす確認できる。

send-mailmessage -SmtpServer (smtpのサーバ) -from (メール発信元) -to (メール宛先) -Subject test -Body test

生成AIで申請文章作ってもらう

Gemini先生やったら、申請の本文こんなふうに作ってくれる。

aws-smtp25

生成AIの文章は長いな。

ウソ書いたら事故ったときツライし、アンチスパム対策の内容とかは見直してから文章使わなアカンで。