procmail
[Top] [All Lists]

Re: Changing From: headers

2001-08-03 16:00:20
Andrew wrote (and I hope Ashley is reading, because the answer I promised
her [him?] two weeks ago and haven't written yet will be similar),

| I'd like to set up a filter that will detect messages "From:" certain
| known addresses then use formail to replace those headers. Specifically, I
| receive mail from several individuals via their cell phones and two-way
| pagers.  I'd like to replace the address of their two-way device in the
| From: line with their regular email address.  Instead of having a seperate
| recipe for each person, I'd like to store the device addresses and "real"
| address in an external file that procmail will reference. Something like
|
| XXXXXXXXXX(_at_)mobile(_dot_)att(_dot_)net address(_at_)domain(_dot_)tld
|
| I'd prefer to do this in sh rather than perl.

Settle for doing them within procmail?

In a subsequent message, you said you don't want to have to edit both
.procmailrc and the external file every time you add or remove a person; in
the general case that would be unfortunate, because you'd need to run
through the routine for every incoming message.  However, we can restrict
the work to messages that are From: addresses @mobile.att.net or a few other
mobile providers.

So here's the external file:

peoplebehindpagers="
pager1(_at_)mobile(_dot_)att(_dot_)net real(_at_)addr(_dot_)ess1
pager2(_at_)some(_dot_)mobile(_dot_)provider real(_at_)add(_dot_)ress2
pager3(_at_)a(_dot_)pager(_dot_)company real(_at_)add(_dot_)ress3
"

and here's the code for .procmailrc (untested):

:0 # brackets enclose caret, space, tab
* ^From:.*\/[^     ]+(_at_)\
   (mobile\.att\.net|some\.mobile\.provider|a\.pager\.company)
{
 pageraddress=$MATCH
 INCLUDERC=.external.file

 :0fwh # note space before extractor
 * $ peoplebehindpagers ?? (^)$\pageraddress \/.+
 | formail -i "From: $MATCH"
}








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