Sender/recipient lists attached to messages
Electronic mail messages are delivered in envelopes.
An envelope lists a sender and one or more recipients. Usually these envelope addresses are the same as the addresses listed in the message header:
(envelope) from djb to root From: djb To: root
In more complicated situations, though, the envelope addresses may differ from the header addresses.
When a message is delivered to several people at different locations, it is first photocopied and placed into several envelopes:
(envelope) from djb to root From: djb Copy #1 of message To: root, [email protected]
(envelope) from djb to [email protected] From: djb Copy #2 of message To: root, [email protected]
When a message is delivered to several people at the same location, the sender doesn't have to photocopy it. He can instead stuff it into one envelope with several addresses; the recipients will make the photocopy:
(envelope) from djb to [email protected], [email protected] From: djb To: [email protected], [email protected], joe, frde
Bounced mail is sent back to the envelope sender address. The bounced mail doesn't list an envelope sender, so bounce loops are impossible:
(envelope) from <> to djb From: MAILER-DAEMON To: djb Subject: unknown user frde
The recipient of a message may make another copy and forward it in a new envelope:
(envelope) from djb to joe From: djb Original message To: joe
(envelope) from joe to fred From: djb Forwarded message To: joe
A mailing list works almost the same way:
(envelope) from djb to sos-list From: djb Original message To: sos-list
(envelope) from sos-owner to [email protected] From: djb Forwarded message To: sos-list to recipient #1
(envelope) from sos-owner to frde From: djb Forwarded message To: sos-list to recipient #2
Notice that the mailing list is set up to replace the envelope sender with something new, sos-owner. So bounces will come back to sos-owner:
(envelope) from <> to sos-owner From: MAILER-DAEMON To: sos-owner Subject: unknown user frde
It's a good idea to set up an extra address, sos-owner, like this: the original envelope sender (djb) has no way to fix bad sos-list addresses, and of course bounces must not be sent to sos-list itself.
Envelope sender and envelope recipient addresses are transmitted and recorded in several ways.
When a user injects mail through qmail-inject, he can supply a Return-Path line or a -f option for the envelope sender; by default the envelope sender is his login name. The envelope recipient addresses can be taken from the command line or from various header fields, depending on the options to qmail-inject. Similar comments apply to sendmail.
When a message is transferred from one machine to another through SMTP, the envelope sender is given in a MAIL FROM command, the envelope recipients are given in RCPT TO commands, and the message is supplied separately by a DATA command.
When a message is delivered by qmail to a single local recipient, qmail-local records the recipient in Delivered-To and the envelope sender in Return-Path. It uses Delivered-To to detect mail forwarding loops.
sendmail normally records the envelope sender in Return-Path. It does not record envelope recipient addresses, on the theory that they are redundant: you received the mail, so you must have been one of the envelope recipients.
Note that, if the header doesn't have any recipient addresses, sendmail will move envelope recipient addresses back into the header. This situation occurs if all addresses were originally listed as Bcc, since Bcc is automatically removed. When sendmail sees this, it creates a new Apparently-To header field with the envelope recipient addresses. This has the strange effect that each blind-carbon-copy recipient will see a list of all recipients on the same machine.
When a message is stored in mbox format, the envelope sender is recorded at the top of the message as a UUCP-style From (no colon) line. Note that this line is less reliable than the Return-Path line added by qmail-local or sendmail.