動かざることバグの如し

近づきたいよ 君の理想に

gmailへメールが送信できなくなったときはメールヘッダーを見ろ

症状

1つのサーバーからSMTPGmailのメールアドレスへメールを送信していたが、いつの日からかメールが届かなかったり、メールが数時間レベルで遅延するようになった。心当たりなかったので、原因がよくわからなかったが、どうもGmail側にスパム認定(Gmailのフィルターの迷惑メールフィルターのことではない)されてしまったらしい

確認1

送信元のサーバーのメールログ /var/log/maillog を見ると以下のようなログがたくさん吐かれていた。

Aug  6 04:15:50 ubuntu postfix/smtp[27570]: B1B5080D4C: host gmail-smtp-in.l.google.com[64.233.189.27] said: 421-4.7.0 This message does not have authentication information or fails to pass 421-4.7.0 authentication checks. To best protect our users from spam, the 421-4.

This message does not have authentication information or fails to passのログが出てたらスパム認定されてる

確認2

v=spf1 include:_spf.google.com ~all

だったのを

v=spf1 include:_spf.google.com ip4:8.8.8.8 ~all

てすと

echo hello | mail -s test -r sousin@example.com uketori@example.com