iyuichiの私的開発ログ

渋谷で働くWebエンジニアのログ. Java, Android, iOS, Docker, GCP, AWS, ゲーム開発

[AWS] Amazon EC2 を使ってみる(postfixの設定)

postfix の設定をしてメールの送受信をできるようにしてみたい。

設定は以下のようにしました。ドメインは伏せさせてもらいます。
ちなみにダイナミックDNSサービス「Dynamic DO!.jp」を使って試しています。

# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, xxxxxx.ddo.jp
mydomain = xxxxxx.ddo.jp
myhostname = xxxxxx.ddo.jp
mynetworks = 127.0.0.0/8, 10.161.0.0/24
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.5.5/README_FILES
relay_domains = $mydestination
sample_directory = /usr/share/doc/postfix-2.5.5/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_client_restrictions = permit_mynetworks, reject_unknown_client, permit
smtpd_helo_restrictions = permit_mynetworks, reject_invalid_helo_hostname
unknown_local_recipient_reject_code = 550

で、試しにメールをGmail等から送ってみたのですがまったく受信される気配なくGmail側にこんなメールが届いた。

This is an automatically generated Delivery Status Notification

THIS IS A WARNING MESSAGE ONLY.

YOU DO NOT NEED TO RESEND YOUR MESSAGE.

Delivery to the following recipient has been delayed:

    xxxxxxxxx@xxxxxxxxx.ddo.jp

Message will be retried for 2 more day(s)

Technical details of temporary failure:
The recipient server did not accept our requests to connect. Learn more at http://mail.google.com/support/bin/answer.py?answer=7720
[xxxxxxxxx.ddo.jp. (50): Connection timed out]

なんだかメールサーバに接続できていないようだ。
しかし、/var/log/maillog とかみても何の痕跡も残っていない。。

あ、ポートを開けてなかった!
ということで、AWS Manager Console の Security Groups でSMTPのポートをあけたら受信できるようになりました。

結構はまってしまった。