サーバーを立ち上げてWordPressサイトを構築

smtp authを有効にして、relay checkして、windowsのクライアントから読み書きのテスト

前記事まででメールの受信と送信ができるようになっていますから、smtp authを有効にします。その前にrelay checkをしておきましょうか?例えば、

ここでホスト名を入れます。下図。

“Check for Open Relay”をクリック

右側にRelay trialの結果が出ますが、全部Not Acceptedならおけです。全部で18種類トライしてます。サーバー側から観てみましょうか?一例ですけど、

18.86.33.178]>: Relay access denied; from=<spamtest@appriver.com> to=<relaytest%appriver.com@[118.86.33.178]> proto=SMTP helo=<appr
iver.com>
Aug 31 10:19:08 ghost postfix/smtpd[195484]: NOQUEUE: reject: RCPT from unknown[40.114.25.37]: 454 4.7.1 <relaytest@appriver.com>:
Relay access denied; from=<spamtest@appriver.com> to=<relaytest@appriver.com> proto=SMTP helo=<appriver.com>
Aug 31 10:19:09 ghost postfix/smtpd[195484]: NOQUEUE: reject: RCPT from unknown[40.114.25.37]: 454 4.7.1 <relaytest%appriver.com>:
Relay access denied; from=<spamtest@appriver.com> to=<relaytest%appriver.com> proto=SMTP helo=<appriver.com>
Aug 31 10:19:10 ghost postfix/smtpd[195389]: warning: unknown[80.94.95.229]: SASL LOGIN authentication failed: (reason unavailable)
, sasl_username=levia@mydns.jp
Aug 31 10:19:10 ghost postfix/smtpd[195389]: disconnect from unknown[80.94.95.229] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
Aug 31 10:19:12 ghost postfix/smtpd[195484]: NOQUEUE: reject: RCPT from unknown[40.114.25.37]: 454 4.7.1 <relaytest@appriver.com@gh
ost.mydns.jp>: Relay access denied; from=<spamtest@chriscain.net> to=<"relaytest@appriver.com"@ghost.mydns.jp> proto=SMTP helo=<app
river.com>
Aug 31 10:19:13 ghost postfix/smtpd[195374]: connect from unknown[81.30.107.6]
Aug 31 10:19:13 ghost postfix/smtpd[195391]: connect from unknown[80.94.95.229]
Aug 31 10:19:15 ghost postfix/smtpd[195484]: NOQUEUE: reject: RCPT from unknown[40.114.25.37]: 454 4.7.1 <relaytest@appriver.com@gh
ost.mydns.jp>: Relay access denied; from=<spamtest@chriscain.net> to=<"relaytest@appriver.com"@ghost.mydns.jp> proto=SMTP helo=<app
river.com>
Aug 31 10:19:19 ghost postfix/smtpd[195484]: NOQUEUE: reject: RCPT from unknown[40.114.25.37]: 454 4.7.1 <relaytest@appriver.com@[1
18.86.33.178]>: Relay access denied; from=<spamtest@chriscain.net> to=<"relaytest@appriver.com"@[118.86.33.178]> proto=SMTP helo=<a
ppriver.com>
Aug 31 10:19:23 ghost postfix/smtpd[195391]: warning: unknown[80.94.95.229]: SASL LOGIN authentication failed: (reason unavailable)
,

rootさんの勤めとしては、mailqや/var/log/mail.logは時々チェックするのが吉です。さて、本題のsmtp authの件ですね。/etc/postfix/main.cfに

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/isp_passwd

smtp_sasl_security_options = noanonymous

smtp_sasl_mechanism_filter = plain, login


smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = ghost.mydns.jp
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, ghost.mydns.jp, localhost.mydns.jp, , localhost
relayhost = [smtpa.jcom.zaq.ne.jp]
#relayhost = [mars.rist.u-tokai.ac.jp]:587
mynetworks = 192.168.0.0/24 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 118.86.33.178

設定を変更したら、systemctl restart postfixでpostfixをリスタートします。上記設定は、プロバイダー内部からメールを出すために、relayしてます。そのための設定が

relayhost = [your_providers_smtp_server]
smtp_sasl_password_maps = hash:/etc/postfix/isp_passwd

です。isp_passwdにはプロバイダのメールアカウントのpasswdを書いておき、postmapします。

さて、テストをしてみますが、筆者はWindowからメールを読み書きするメールクライアントとしては、Becky!を使うのですが、その設定例を示した上で、smtp authのプロトコルが動くことを示します。

ここからダウンロードします。smtp authを活かした設定例は、

詳細は、

これでメールが送れればOKですが、Becky!にはプロトコルのログを取る機能があるので、試してみましょう。新規メールを書きかけて、

上図のプロトコルログを取るを選択して、メールを送信します。

>>> Connecting to "ghost.mydns.jp" [2025/08/31 11:16:23] <<<
220 ghost.mydns.jp ESMTP Postfix (Debian/GNU)
EHLO [192.168.0.118]
250-ghost.mydns.jp
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250-SMTPUTF8
250 CHUNKING
AUTH LOGIN
334 VXNlcm5hbWU6
235 2.7.0 Authentication successful
RSET
250 2.0.0 Ok
MAIL FROM:<nao@ghost.mydns.jp>
250 2.1.0 Ok
RCPT TO:<jake.burst@gmail.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
.
250 2.0.0 Ok: queued as A510064E119E
QUIT
221 2.0.0 Bye

動いているようです。

コメント