procmail
[Top] [All Lists]

Re: need to replace sender's email address

2002-10-18 10:34:55
At 10:47 2002-10-18 -0400, Vlad wrote:

When I get an incoming mail to my(_at_)my(_dot_)com,

To:, Cc:, Bcc:, or is the fact that you received it HERE sufficient?

I want procmail to replace sender's e-mail address with his(_at_)my(_dot_)com 
and
then forward it to hers(_at_)my(_dot_)com(_dot_)

literal his(_at_)my(_dot_)com, or some programmatic implementation wherein the username portion from the original message is tacked onto a @my.com ? And is hers(_at_)my(_dot_)com a static address?

"sender's" address is a misnomer - I suspect you're referring to the "From:" field, but the sender's address may appear literally in "Sender:" (say, for list messages), and of course the From_ (which, when you remail, your server will end up rewriting), or the Return-Path: and Reply-To: headers. There's lots of places to find the "senders" address.

if anyone could help with the syntax, I would really appreciate it.

This should work to do what I _interpret_ your request to be:

:0
* ^TO_my(_at_)my\(_dot_)com
* ! ^X-Loop: my(_at_)my\(_dot_)com
| formail -I "From: his(_at_)my(_dot_)com" -A "X-Loop: my(_at_)my(_dot_)com" \
        | $SENDMAIL hers(_at_)my(_dot_)com -f his(_at_)my(_dot_)com

If you want _all_ mail arriving here to be treated as being "to" the my(_at_)my(_dot_)com address, then eliminate the first condition. If you want to retain a copy of the unaltered message, add a 'c' flag to the flags line. If you want to retain the original From: in the forwarded message, change the '-I' in the formail invocation to '-i'.

Note that the To:/Cc: fields are NOT changed in the rewritten message (you're redirecting it to the other address, but they're effectively receiving it as a Bcc:). Before you argue the logic of that, consider that if there are addresses other than your own in the To: or Cc: fields, so you shouldn't just change those fields to be something else, so how do you figure you'll rewrite them? You could pass the message headers through a sed script to change my(_at_)my(_dot_)com to hers(_at_)my(_dot_)com, but I'll leave that exercise up to you.

Additionally, by using the '-f addr' parm to sendmail, your envelope sender information should be changed to be this other address you're claiming the message is from (more properly reflecting that address as the sender).

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>