LoginSignup
4
3

More than 3 years have passed since last update.

EC2からメールを送信する(ポート 25 に対する制限を解除)

Last updated at Posted at 2021-03-17

概要

最近新規で作成したAWSアカウントで起動したEC2からgmailのメアドへメール送信してみたが、メールが届かなかった。
maillogを見ると、google の メールサーバへの接続が Connection timed out になっていた。

メールを送信したEC2のあるSubnetのネットワークACLでは25番ポートのOutboundは許可しているし、SecurityGroupのアウトバウンドルールでも25番ポートは許可している。

調べたら、どうやらこれが原因だとわかった
https://aws.amazon.com/jp/premiumsupport/knowledge-center/ec2-port-25-throttle/

解除申請 1回目

メールを送信したいEC2があるAWSアカウントにサインインした状態で、次の解除申請フォームへアクセスする。
https://console.aws.amazon.com/support/contacts?#/rdns-limits

フォームの文言は英語だ。。

英語苦手なので、日本語で入力して申請してみる。

  • Request information

    • Email address
      • ここに入力するメールアドレスは、この申請をやり取りをするためメールアドレス。
      • 実在して、実際に送受信ができるもの。
      • 解除申請を依頼するユーザ側の担当者のメールアドレスにしておく。
  • Use case description

    • なぜメール送信をしたいのかという、具体的な理由を書く。
    • 日本語で入力してみた
      
      EC2 (i-**********) のcronから実行されるバッチジョブのレポートをメールで送信したいです。
      1日10通ほどです。
      このEC2に割り当てているセキュリティグループではインバウンドの25番ポートは開けていません。
      
  • Elastic IPs information

    • 今回は、逆引き設定はしないので、空にしておく

こんな感じでSubmit

解除申請 2回目

  • 解除申請1回目を送信してから、24時間も経たないうちに、Request information の Email address に入力したメールアドレスに、AWSの申請担当者からメールが送られてきた

Hello,

Thank you for submitting your request to remove your email limit.

In order for us to process this request as quickly as possible, please provide the following information:

* Elastic IP Address(es)
* A clear/detailed use-case for sending mail from EC2.
* A statement indicating how you intend to ensure this account is not implicated in sending of unwanted mail.

We appreciate your cooperation, as soon as we receive this information we can move forward with your request.

If you have any questions, please reach out to us.

Regards,
Amazon Web Services

あ、また英語だ・・
めげずにまた日本語でこのメールに対して、単に↓みたいな本文でメール返信してみる


* Elastic IP Address(es)
x.x.x.x.x (EC2 i-**********)

* A clear/detailed use-case for sending mail from EC2.
EC2 i-********** の cron 実行されるシステムの稼働状況バッチのレポートをメールで送信したいです。

* A statement indicating how you intend to ensure this account is not implicated in sending of unwanted mail.
1日10通程度のメールを送信します。

※ Elastic IP Address は、メールを送信したい EC2 i-********** に割り当てているEIPのIPアドレスを入力した

解除申請 クリア!

  • 解除申請2回目を送信してから数時間後で、解除メールが届いた!

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.

Because reverse DNS record entries are commonly considered in anti-spam filters, we recommend assigning a reverse DNS record to the Elastic IP address you use to send email to third parties. Please use the form located at this link to request a reverse DNS entry:
https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request

If you'd like to proceed with assigning a reverse DNS record to the Elastic IP, the first step would be to configure the A record for the domain to match the desired PTR record on your side.

Please follow the instructions at the link below to create the A record:
https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-creating.html

Please let us know if you have any questions.

Regards,
Amazon Web Services

試しに、申請解除したEC2(EIP)からメールを送信してみた

$ mail nishimura.toru@example.com
Subject: test
test
.
EOT


メールが届いた。
けど、gmail ではスパムとみなして、迷惑メールに振り分けられた。

「迷惑メールでないことを報告」を押下しておけば、2回目からは受信トレイに振り分けられる。
1回目から迷惑メールとみなされないようにするためには、解除メールにあったように、事前に逆引き設定申請をしておいたほうが良さそう。

所感

  • 少し前までは、解除申請の審査はここまで厳しくなかった。
  • 解除申請 1回目で入力した、「Request information の Email address に入力したメールアドレス」の本人確認のため、わざと2回目の解除申請を出すような仕組みにしているじゃないかと。
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3