procmail
[Top] [All Lists]

Re: Changing "From:" header

2002-10-18 10:36:07
At 11:12 2002-10-18 +0200, Nikolaus Hiebaum wrote:

:0:
* ^From: (_dot_)*sender(_at_)theirdomain\(_dot_)com
* !^FROM_DAEMON
* !^X-Loop: myaddress(_at_)domain(_dot_)com
| (formail -rI "To: myaddress(_at_)domain(_dot_)com" \
        -A "X-Loop: myaddress(_at_)domain(_dot_)com" \
        -i "From: Senders Name <sender(_at_)domain(_dot_)com>) \
| $SENDMAIL -oi -t

You really should avoid using sendmail in that fashion. Besides being unnecessary (if you're just looking to change the text and drop it into your LOCAL mailbox anyway, why REMAIL the message?), it's also problematic. Consider if the original message included a Cc: header:

        Cc: someotheraddress

-t will send your rewritten message to that address as well! (assuming that the -r doesn't twiddle with that anyway, but there are other issues with the recipe anyway). If you must use sendmail in this fashion, pass the recipient address on the commandline to sendmail, then there is no confusion about who is receiving a copy and you don't blintz other people with additional copies (of a changed message at that).

Note also that the ! ^FROM_DAEMON isn't very useful if your condition is ALREADY conditioned on a specific From: address (which certainly doesn't appear to be a daemon), so it would be superfluous.

If you don't really need to resend it, you don't need to change the To: (which also changes the character of the message - what if you received a message which was really sent to multiple people?), or add an X-Loop:, so the filter gets VERY simple:

:0hf
* ^From: (_dot_)*sender(_at_)theirdomain\(_dot_)com
| formail -i "From: Senders Name <sender(_at_)domain(_dot_)com>"

That should add your Old-From, takes less processing time, and lets the message continue along through your procmailrc, to be delivered however you'd be delivering email from this buddy.

Basically, it works, but I noticed that formail -i does create a new
"From" but does *not* create an "Old-From" header.

I won't bother to diagnose exactly why, but I'd venture to guess that it probably has a LOT do with you using the -r flag. Also, your last header operation lacks a closing quote, and the lockfile flag is inappropriate, as you're not delivering to a file. I'm sure I missed a few other problems as well.

intervention, he refuses to change this, which would obviously be the
easiest part, but he is afraid he will loose his e-mail.

If he has multiple email address capability (his own domain for instance), he could simply create a different account and use it instead, aliasing the delivery of mail to the original account to the new address. Then he doesn't lose email addressed to the old address. After some period, he could formally discourage the use of the old address by changing the virtusertable entry to bounce a message about the address having been changed (this, after he's formally notified friends that he's changed his address of course).

Surely in rewriting the From:, you're changing the ADDRESS of your friend? If so, why can't he just use that other address in the first place? And if not - if what you're really doing is stripping the name text portion from the From: field, he should be able to change that and it certainly won't affect his email delivery.

Another thing to consider is just _fixing_ Pine so that it supports this symbol you're dealing with.

---
 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>