10.7 Bounce Handling

Sometimes a message can't be delivered to the intended address. The process of dealing with an undeliverable message is known as bouncing the message, and a message sent back to report a delivery failure is known, somewhat ambiguously, as a bounce. Sometimes a bounce message can't be delivered, leading to a double bounce and, if a double bounce can't be delivered, occasionally to a triple bounce.

Bounces can originate in two ways. A message sent to a local address can bounce either because the address doesn't exist or because a program run from a qmail file exits with code 100 to tell qmail to bounce it. (There is considerable overlap between these two causes. Many qmail systems have a global default qmail file ~alias/.qmail-default that runs fastforward to look up the address in a sendmail-style /etc/aliases file. If the address isn't in the file, fastforward exits with code 100, which causes a bounce. From the point of view of the sender, the two kinds of local bounces look the same.) A message sent to a remote address may have an invalid domain with no DNS information, or the server(s) that handle that domain aren't available or won't complete an SMTP delivery, or the remote server may explicitly reject the recipient address or the entire delivery using a 4xx or 5xx error code.

In each case, qmail usually generates a bounce message and mails it back to the envelope sender of the original message. If the envelope sender is null, which is the case if the bouncing message is itself a bounce message, qmail handles it as a double bounce and treats it specially, as discussed next.

10.7.1 Single Bounces

If a message delivery attempt bounces, qmail sends a bounce message back to the sender. If a single message is sent to multiple addresses, all of the bounce reports are sent back in a single message.[5] Qmail produces bounce messages in qmail-send Bounce Message Format (QSBMF) that Dan Bernstein designed as a much simpler alternative to the rather baroque Delivery Status Notices (DSNs) defined in RFCs 1892 and 1894. (Qmail does use the three-part error numbers defined in RFC 1893, though.) QSBMF is defined in detail at http://cr.yp.to/proto/qsbmf.txt. Here's a typical QMSBF bounce message:

[5] A message can have multiple addresses if it is injected locally with multiple recipients, if a .qmail file remails it to multiple addresses, or if the message arrives via SMTP from a system that, unlike qmail, delivers to multiple recipients in a single SMTP transaction. If a message is sent from qmail system A to multiple invalid recipients on system B, system A sends a separate copy of the message to each recipient, so system B sees all the copies as separate messages. If system B rejects invalid addresses in the SMTP transaction, as sendmail systems usually do, the rejections are all be collected by system A into a single bounce message. But if system B accepts the messages and bounces them later, as qmail does, it sends back its own separate bounce messages for each address that bounces in whatever format B's mail system produces.

Return-Path: <> Received: (qmail 17296 invoked for bounce); 19 Jul 2003 11:30:58 -0400 Date: 19 Jul 2003 11:30:58 -0400 From: MAILER-DAEMON@tom.iecc.com To: ChrissyFoster52@yahoo.com Subject: failure notice Hi. This is the qmail-send program at tom.iecc.com. 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. <regan@iecc.com>: Sorry, no mailbox here by that name. (#5.1.1) <scarlett@iecc.com>: Sorry, no mailbox here by that name. (#5.1.1) <scorpio@iecc.com>: Sorry, no mailbox here by that name. (#5.1.1) <shay@iecc.com>: Sorry, no mailbox here by that name. (#5.1.1) <shelton@iecc.com>: Sorry, no mailbox here by that name. (#5.1.1) --- Below this line is a copy of the message. [ a complete copy of the bounced message appeared here ]

The message is a sequence of paragraphs separated by blank lines. The first paragraph starts with the string Hi. This is the to identify the message as a QMSBF report. (Yes, Dan has an odd sense of humor.) Subsequent paragraphs start with < to report failing addresses. Each failed address appears in angle brackets on the first line of the paragraph. A paragraph that starts with a hyphen is the break paragraph, which indicates that the rest of the bounce message is a copy of the message that bounced. Each paragraph can and usually does include explanatory text for the benefit of people reading the bounce, so the computer doesn't need to try to interpret the rest of the text.

QMSBF messages are designed to be extremely easy for computer programs to parse, so that mailing list software can tell what list addresses are bouncing and do something about it. (See Chapter 14.)

You can control the return address in the From: line of single bounces if you want, although in practice the defaults are invariably fine. The local part defaults to MAILER-DAEMON but is overridden by the contents of bouncefrom in /var/qmail/control if that file exists. The domain defaults to the local hostname from me but is overridden by bouncehost if that file exists.

10.7.2 Double Bounces

Single-bounce messages have a null envelope sender address, because the sender is a computer program that is unlikely to understand a response. If a message with a null sender bounces, that's a double bounce. In practice, most double bounces are due to incoming spam with forged return addresses.

Qmail normally sends double bounces to postmaster at the local host, but the local part and domain of the double-bounce target address can be overridden by the contents of doublebounceto and doublebouncehost. The From: line return address is set the same as in single bounces, but the envelope sender is set to the impossible address #@[ ].

The vast majority of double bounces are now due to spam with forged return addresses, so some system managers find that wading through them is more trouble than it's worth. To get rid of double bounces, create an address "nobody" that discards all mail sent to it by putting a line with a single # into ~alias/.qmail-nobody. Then put nobody into doublebounceto to send the bounces there. If your system generates many double bounces, there's a small patch to qmail-send at www.qmail.org called doublebounce-trim that discards double bounces directly if doublebounceto exists but contains a blank line.

10.7.3 Triple Bounces

If a double-bounce message bounces, which should never happen because postmaster is supposed to be an address that's always valid, qmail logs the failure and discards the message. This means that if you want to send mail within your qmail system that doesn't provoke bounce messages if it's undeliverable, set the envelope sender to #@[ ].



qmail
qmail
ISBN: 1565926285
EAN: 2147483647
Year: 2006
Pages: 152

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net