僕の備忘録(PC、UN*X、ネットワーク関連が中心)なんです。
自分の書いたところは適当(な時とか)に書き換えますので御了承を。
大体
Debian Wikiを頼りに、
VPS上にWordPressを構築してみた。
v4、v6とも通す。fwpで特定IP以外の接続は蹴るように設定し、
certbotでhttpsも有効にしておいた。
新規ユーザを作り、メールでその旨を送信させてみる。
何も届かず、/var/log/apache2/error.logに、
sh: 1: /usr/sbin/sendmail: not found sh: 1: /usr/sbin/sendmail: not found sh: 1: /usr/sbin/sendmail: not found
ローカルホストにメールサーバが走ってる前提のようだった。
とりあえず、Postfixをぶちこんでみた。
以下、届いたメール。
To: $USER_MAIL_ADDR Subject: [$MY_WORDPRESS_SITE] パスワードのリセット Date: Mon, 10 Jan 2022 01:13:25 +0000 From: WordPressSomeone has requested a password reset for the following account: Site Name: $MY_WORDPRESS_SITE ユーザー名: $USER If this was a mistake, ignore this email and nothing will happen. パスワードをリセットするには、以下へアクセスしてください。 https://$MY_WORDPRESS_SITE/wp-login.php?action=rp&key=HOGEHOGEHOGE&login=$USER
メールヘッダ適当に。
Return-Path:X-Original-To: $USER_MAIL_ADDR Delivered-To: $USER_MAIL_ADDR Received: from localhost ($VPS_HOSTNAME [IPv6:$ADDR]) by $MY_MAIL_SERVER (Postfix) with ESMTPS id 79CF040043 for <$USER_MAIL_ADDR>; Mon, 10 Jan 2022 10:14:09 +0900 (JST) Received: by localhost (Postfix, from userid 33) id AAE661000A3; Mon, 10 Jan 2022 10:13:25 +0900 (JST) X-Mailer: PHPMailer 6.5.0 (https://github.com/PHPMailer/PHPMailer) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit
これじゃ多くのメールサーバに受け取ってもらえないだろうな。
hostnameをPostfixのmain.cfに入れたりし、SPFも追加したが、
それでもGmailに跳ねられた。
Jan 10 10:59:33 localhost postfix/smtp[19635]: 53910102812: to=<$USER@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.23.27]:25, delay=2.1, delays=0.01/0/1/1, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[74.125.23.27] said: 550-5.7.1 [$IPv4 12] Our system has detected that this message is 550-5.7.1 likely unsolicited mail. To reduce the amount of spam sent to Gmail, 550-5.7.1 this message has been blocked. Please visit 550-5.7.1 https://support.google.com/mail/?p=UnsolicitedMessageError 550 5.7.1 for more information. d14si5202918pgi.540 - gsmtp (in reply to end of DATA command))
名前をMXに合わせた環境(canonical_maps追加)でs-nailにてテストメールを 送信したら、こちらは迷惑メール扱いにもならず受け入れられた。
プラグインのメールはローカルホストよりgmailでも使っているかもしれない。
リンクはご自由にどうぞ。でもURLや内容が変った場合はあしからず。