The problem was:
I'm capturing all email for a domain into one mailbox, using procmail.
Works fine. I'm doing this so I can read each "To:" header field and
send the body of the email to a fax machine (The "To:" field contains
phone number & related information).
This works great _except_ on email originating from mailing lists.
Mailing list mail has the list name (i.e. sample-list(_at_)foobar(_dot_)com)
in the
"To:" field, effectively obliterating the "real" address (which is
strange as the email arrives at the machine just fine).
My question: How can I capture the "real" To: address of email arriving
from mailing lists?
The cause: mail is sent to the "To:" address in the envelope, not the "To:
address in the header (which is normal).
The solution: Before passing incoming email to procmail, copy the envelope
"To:" address to a unique header (I chose X-Full-Name:) and then modify the
procmail recipe to look at this header. Here's how I modified sendmail.cf:
a) I added a flag called "x" to the procmail delivery agent, thus:
Mprocmail, P=/usr/local/bin/procmail, F=mSDFMhunx, S=11, R=21,
A=procmail -m $h $f $u
Notice the "x" in the F section - that's what I added.
b) Then I added the custom header in the header section, thus:
H?x?X-Full-Name: $u
This tells sendmail to add this header line to a mail message if the delivery
agent also contains the "x" flag. The $u is a predefined sendmail macro that
contains the envelope "To:" address.
Thanks again to all who replied to my original inquiry!
Brian Rankin