Bounce loops

Forwards, bounces and loops

When using procmail, care must be taken that the rules do not result in loops, especially considering that e-mail may be bounced when it cannot be delivered to a destination mailbox. Consider the following situtation:

  • A sends a mail to B
  • B has a .procmailrc that resends the mail to P, Q, and R:
    ! P Q R

    Note that this means that the e-mail now appears to come from B.

  • The e-mail to address P bounces, for example because P's mailbox is full.
  • The bounce goes back to the sender B
  • Because the e-mail did not originate from B, the .procmailrc rules get executed again.
  • Therefore, mail gets sent to P again, leading to a loop.

Note that this happens because the system was unable to detect that the forwarded e-mail originated from B. Note also that this is different from the "traditional" way of forwarding by putting the e-mail address in ~/.forward. In that case the original sender is preserved.

The loop in the ~/.procmailrc forward can be prevented in one of two methods.


The first method is by means of the empty Return-Path header that is sent in the header of a bounced e-mail.

Return-Path: <>

You can prevent rules from executing when this header is present by adding a line to those rules in your ~/.procmailrc:

* !^Return-Path: [<][>]
! P Q R


The second method is to make sure that the bounce is sent to the original sender, A. This can be done by making sure that the forward leaves the original sender intact. You can do this by setting the SENDMAILFLAGS variable in your rules:

! P Q R

Unforunately this only helps if A does not have any (in)direct forwards to P.

Contact us | Webmaster

Questions? Mail to