コンテンツにスキップ

Top

Gmail に送信できない!

VPS上にpostfix(と dovecot) でメールサーバを構築。したのはいいのだけど、gmailからの受信はできるけどgmail宛に送信ができない。
以下のようなエラーが返ってくる。

Undelivered Mail Returned to Sender

This is the mail system at host jitaku.work.

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.

さらに詳細を読んでいくと、

This mail has been blocked because the sender is unauthenticated.
550-5.7.26 Gmail requires all senders to authenticate with either SPF or DKIM.
とあり、どうもSPFかDKIMで認証をしなさいとのこと。

DKIMは証明書云々とか出てきて面倒なのでとりまパスして、SPFの設定をすることに。
これは結構簡単だった。

Conoha の DNS に SPF設定を追加する

SPFの設定ってなにすんの?postfixの設定変えんの?とか思ったら、DNSにSPFレコードを追加するとのこと。

ConoHaの設定でDNSのドメインリストを開き、

TXT @ 3600 v=spf1 ip4:xxx.xxx.xxx.xxx/23 ~all
(xxx.xxx.xxx.xxxはこのサーバのIPアドレス。ip aコマンドで表示されるやつね)

と設定。数時間時間をおいてからメールを送信したらちゃんと送信できた!
ちなみに最後の、~allは-allにしたらダメだった。なんでかはしらん。-allのほうが厳密らしいんやが。

以上!