procmail
[Top] [All Lists]

Re: sendmail & procmail - recipients

1996-09-15 23:14:39
Unfortunatly, both are Sendmail issues.  The first one, NOBODY has every
been able to tell me how to do it.  I'm about 3/4 of the way through
Avolio & Vixie's book "Sendmail: Theory and Practice" so I can try to figure
it out myself :)  I've posted to comp.mail.sendmail with no responce on 
how to do it.  The one person I talked to via email said it was in the
procmail docs, which I've searched through several times and can't find.

The following is from a message Brian Rankin posted to the Procmail list
last April.  I don't have his explicit permission to repost it, but I'm
hoping it okay given that the message is in the archives (somewhere).
Consider this a shortcut to the archived version...

Note: I have not implemented this and and can't say it will or will not
work.  I just saved the message knowing I'll need it eventually!

 _
| |
|-|
| |pu <apu(_at_)spfld(_dot_)com>

---------- Forwarded message ----------
Date: Mon, 8 Apr 1996 13:17:26 -0700 (PDT)
From: Brian Rankin <brankin(_at_)WestEd(_dot_)org>
To: procmail(_at_)Informatik(_dot_)RWTH-Aachen(_dot_)DE
Cc: gregg(_at_)wwti(_dot_)iway(_dot_)net
Subject: Address problem solved:  Thanks, everybody!
Resent-Date: Mon, 8 Apr 1996 23:17:16 +0200
Resent-From: procmail(_at_)Informatik(_dot_)RWTH-Aachen(_dot_)DE

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