Gmailに送るとエラーメッセージが返ってきてしまう
先日、Gmailにメールを送ると、必ずエラーメッセージが返ってくる、という現象が発生しました。
アカウントを変えて送っても、同じドメインからのメールはすべてエラーになってしまいます。
また、送る先のGmailも、アドレスを変えてもエラーを返してきます。
原因
Gmailのエラーメッセージの内容を確認すると、このメールは認証できなかった、とあります。
SPFもしくはDKIMで認証してください、ということのようです。
This is the mail system at host xxx.xxx.xxx.
I’m sorry to have to inform you that your message could not
be delivered to one or more recipients. It’s attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
<xxx@gmail.com>: host gmail-smtp-in.l.google.com[xx.xxx.xxx.xx] said:
xxx-x.x.xx This mail is unauthenticated, which poses a security risk to the
xxx-x.x.xx sender and Gmail users, and has been blocked. The sender must
xxx-x.x.xx authenticate with at least one of SPF or DKIM. For this message,
xxx-x.x.xx DKIM checks did not pass and SPF check for yyy.yyy.yyy] did
not xxx-x.x.xx pass with ip: [yyy.yyy.yyy.yyy]. The sender should visit
xxx-x.x.xx https://support.google.com/mail/answer/81126#authentication for
xxx-x.x.xx instructions on setting up authentication.
xxx.xxx – gsmtp (in reply to
end of DATA command)
Gmailは、2022年3月から、メールのセキュリティを強化しており、メール送信時にSPF又はDKIMによる認証設定をしていないとスパムメールとして扱う、ということになったのが、原因のようでした。
対処法
サーバ側でSPFレコードの設定をすることでGmailで受け取ってもらえるようになります。
各サーバのコントロールパネルで管理画面に行き、SPFレコードの設定をします。
私の場合は、Kagoyaを使っていました。
Kagoyaの場合、SPFレコードの設定はしなくても自動的に設定がされている、ということで、DNSレコードの設定画面を見ても何も表示されていないのですが、SPFレコードの設定を確認するサイトで見ると、「設定されている」と表示されていました。
このDNSレコード設定を必要があって変更した際に、自動的に設定されるSPFレコードの設定が消えてしまったようです。
SPFレコードの設定を明示的に追加したら復旧しました。
なお、SPFレコードの設定が反映されているかは、以下のサイトで確認することができます。
https://www.kitterman.com/spf/validate.html
ここで、ドメイン(xxx.comなど)を入力して「Get SPF Record」ボタンを押すと、設定の有無や設定値などを見ることができます。
関連記事