procmail
[Top] [All Lists]

Re-write outbound Received: mail headers

2005-11-29 01:34:58
Users on a private network behind a NAT'ing firewall (fw.domain1.com) 
have an occasional need to send mail to an smtp host (smtp.domain2.net) 
for delivery to mailing lists, etc. Actually, corporate policy 
precludes use of the name "domain1" in such messages. Therefore, a 
solution is to use smtp.domain2.net as a relay for users in 
domain1.com. (Please - I'm not here to debate the policy). 

When I was asked to set this up, I thought masquerading was the answer. 
However, masquerading has no (apparent) effect on the Received: header. 
The example below shows headers contained in a message sent from a host 
at 192.168.1.75 to listowner(_at_)listserver(_dot_)somewhere(_dot_)org:

< header # 2 > 
Received: from smtp.domain2.net (root(_at_)smtp(_dot_)domain2(_dot_)net 
[A.B.C.D]) 
    by listserver.somewhere.org (8.13.3/8.13.3) with ESMTP id 
jAV5B8sC227318 
    for <listowner(_at_)somewhere(_dot_)org>; Tue, 22 Nov 2005 23:11:08 -0600 
(CST) 

< header # 1 > 
Received: from [192.168.1.75] (fw.domain1.com [E.F.G.H]) 
    by smtp.domain2.net (8.13.4/8.12.11) with ESMTP id jAV5B7N6018915 
    for <listowner(_at_)somewhere(_dot_)org>; Tue, 22 Nov 2005 23:11:07 -0600 
(CST) 


header #2 was added by the host 'listserver.somewhere.org', and is fine 
of course; header #1 shows the issue I'm trying to overcome. I want to 
remove or actually re-write the references to fw.domain.com, and its ip 
address E.F.G.H. For *relayed mail only* (i.e. mail sent from 
smtp.domain2.net to another destination), I want to re-write the 
Received: header such that the message appears to have originated at 
smtp.domain2.net rather than from a host in the private address space 
behind fw.domain1.com. 

In summary, I want to re-write header #1 as follows:

Received: from [192.168.1.75] (fw.domain2.net [A.B.C.D])
    by smtp.domain2.net (8.13.4/8.12.11) with ESMTP id jAV5B7N6018915
    for <listowner(_at_)somewhere(_dot_)org>; Tue, 22 Nov 2005 23:11:07 -0600
(CST)

I understand that re-writing Received: headers is a somewhat 
controversial subject, and can lead to all sorts of problems if it's 
not done correctly. I need a solution that's maintainable - I think 
procmail can do this based on Weldon Whipple's "How-To" document at: 
http://www.technoids.org/procmailfilter.html, and a "recipe" in the 
sendmail Cookbook. Both, however, seemed to stop short of where I need 
to go.

Q: Can procmail do this?

Thnx,
Jay


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail