cancel
Showing results for 
Search instead for 
Did you mean: 

Mailing Loop Avoidance

Steve Bonds
Trusted Contributor

Mailing Loop Avoidance

I would like to set up a number of systems to forward mail to "root" to a central mailing list.

However, if a mail bounces from this list for any reason a mailing loop will be created since the return message goes back to root, which is then forwarded back to the list address. Repeat ad infinitum.

What is the best way to avoid this problem?
4 REPLIES
Christopher Caldwell
Honored Contributor

Re: Mailing Loop Avoidance

The inelegant way:

Make sure there aren't any errors ;-).

The elegant way:

Use procmail to add extended headers to the e-mail. Use the same recipe to distribute to the list. The recipe should anchor on the extended header and deliver mail to a local recipient (not the list) if the head is found.
Save a local copy for safe keeping.

The recipe might look something like this:
:0 c
* !^X-Loop: mail-to-root
| formail -A "X-Loop: mail-to-root" | $SENDMAIL -oi list@domain.com

:0
localmailbox
Christopher Caldwell
Honored Contributor

Re: Mailing Loop Avoidance

BTW, "Repeat ad infinitum" should never happen. At most, sendmail will relay the mail MaxHopCount times (I believe MaxHopCount is 25 by default).
Robin Wakefield
Honored Contributor

Re: Mailing Loop Avoidance

Hi Steve,

What do you want the bounces to do? Do you want them sent back to the originating server (but not to root), or would you want them sent to a separate account?

When the messages arrive at your central server, what is the sender being set to? Is it a generic root@yourcompany.com, or root@host.yourcompany.com, or something else?

Rgds, Robin.
Steve Bonds
Trusted Contributor

Re: Mailing Loop Avoidance

Chris:

Thanks for the good procmail suggestion. Since we don't have procmail available on HP-UX by default, I'm holding this as a final option since implementing it enterprise-wide is likely to be more time/effort than just cleaning up from the ocassional mail storm.

Also, once we have an Exchange server involved the 25 max hops can get muddled since Exchange seems to be generating a fresh new no-hops message for each bounced mail. (Maybe mailing loop is the wrong term, perhaps mail amplifier is more descriptive... )

Robin:

Unfortunately, I have little control over what happens to the bounces. They will be sent back to root at the original server by the Exchange server managing the mailing list.

The sender (From: line) is left unaltered (root@host.domain).