LoginSignup
1
3

More than 5 years have passed since last update.

身に覚えのない mail loop に悩まされたら、Delivered-To ヘッダを見よ

Posted at

問題

運用中のメールサーバから、一部のメールサーバにメールを送ったときだけ、相手方の MAILER-DAEMON からエラーが返ってきて、メールが送れないという問題に悩まされた。自前で運用していた qmail から返ってきた応答は以下のようなもの。

Hi. This is the qmail-send program at <受信側のホスト>.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<受信者メールアドレス>:
mail is looping

--- Below this line is a copy of the message.

Return-Path: <送信者が設定した Return-Path >
:

postfix も以下のようなエラーメールを返してきた。

This is the mail system at host <受信側のホスト>.

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

<受信者メールアドレス>: mail forwarding loop for <受信者メールアドレス>

調査

mail loop とはあったが、配送先のメールアドレスやサーバにループするような設定は見当たらない。送信時の処理に何か問題がありそう、といったところで、以下に辿り着いた。

早期にメール転送ループを止めるために、ソフトウェアは最終的なエンベロー
プ受信者アドレスを持つ Delivered-To: ヘッダをオプションで付け加えます。
すでに Delivered-To: ヘッダに載っている受信者へのメールが届くと、メッセ
ージはバウンスされます。

ループしているかどうかの判定に Delivered-To ヘッダを参照しているらしい。

そういえば以前、メールの送信前処理として Postfix の content_filter を仕込んだ際に、前処理に必要な Delivered-To を付加していたんだった。本来受信サーバ側で(配送/転送先を示すために)付加されるものなので、このまま配送していてはマズい。ということで、除去。解決。

まとめ

mail is looping といっても、かならずしも受信側に問題があるとは限らないよ、という話(というか、メールヘッダは適切に運用しましょう反省)。

参考

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3