Eugene Geldenhuys <eugeneg(_at_)tfx(_dot_)com(_dot_)au> writes:
I have looked at the FAQ and scoured the web for a recipe to
perform the function I require.
The closest I got was the following:
# Procmail recipe file to sort incoming mail to individual mailboxes
As you can see the intention is to redirect mail to user's local
mailboxes - it works, but does not filter some leading and trailing
characters attached to the recipient name such as " ' ` < > ( ).
I tried a few filters, but to no avail.
How many times do I have to say it: YOU CANNOT RELIABLY AND CORRECTLY
ROUTE EMAIL USING THE ADDRESS(ES) IN THE HEADER.
There are two types of addresses: header and envelope. The header
recipient addresses are the ones you find in the To: and Cc: header
fields. The envelope recipient addresses are passed around outside of
the message itself using protocol dependent methods. When a message is
being transfered via SMTP, the envelope recipient addresses are
transmitted via the RCPT To: command. When procmail is used for
non-virtual local delivery, the recipient addresses are passed on the
command line. When you create a virtual domain, you must somehow save
that envelope information for actual routing of the message to the true
The header/envelope distinction exists for the sender as well and is
important when replying to messages: delivery failure messages (e.g.,
"no such user") and vacation messages should be sent to the _envelope_
sender (as passed via SMTP's MAIL From: command) while normal 'content'
replies should go the header sender. Fortunately, the envelope sender
is normally saved automatically in the Return-Path: header field and,
for mbox style mailboxes, in the "From " message separator. When using
formail to generate an auto-reply, the -t flag controls whether an
envelope reply or a header reply is done; check out the discussion on
the manpage for details. If your manpage doesn't have a paragraph
talking the distinction then you need to upgrade your formail.
Why is this important? Without the true envelope information, you
cannot correctly handle messages from mailing lists, or Bccs. Resent
messages will probably be delivered to the wrong person without any
warning. If that list of effects don't scare you, you shouldn't be
administering mail systems.
So, how do you save the envelope recipient information when creating a
virtual domain? It completely depends on how your're doing the domain.
The most common technique is to save the envelope recipient information
in a header field ("X-Envelope-To:" is common) and then route the
message based on that. If you do that, you should be careful to
*remove* that field before final delivery to avoid leaking private
information (the list of recipients) to people who shouldn't have it.
Other techniques exist, so keep your eyes open when you look at your
In the end, ^TO and ^TO_ are _not_ useful for routing mail and if you're
using them, you are probably mishandling messages.
procmail mailing list