procmail
[Top] [All Lists]

Re: Removing an address from To & Cc headers.

2010-01-14 04:33:59
On Tue, 2010-01-12 at 08:09 -0800, Professional Software Engineering
wrote:
At 17:15 2010-01-12 +0200, Tony K Lindstrom wrote:
:0
* ^TO(testipelle|kestipelle|toberemoved)
{
        ORIGTO=`formail -c -xTo:`
        ORIGCC=`formail -c -XCc:`

Note that the case of the 'x' in these two lines is different.  Given what 
you're doing with the lines, you don't want to retain the header in that 
second one.  Further, you can extract BOTH headers at the same time and 
combine them (since that's what you're doing anyway):

        Yes, sorry that was a typo. There really is small x:s on both. That was
a leftover from my tests.


         NEWCC=`(formail -c -xTo: -xCc:|tr -s '\n' ',')`

        Yes, that is better (with the revised sed added version), but the
reason I used "my" version is, that then I have a possibility to check
what were in what header in the  original mail. (By echoing the
$ORIG..:s to a log file. Didn't implement it yet, though) 


That should take the contents of To and Cc then replace newlines with 
commas (eliminating multiple newlines, if any, before doing so).  Try it at 
a commandline.  This will properly handle instances where a message has 
more than one Cc: or To: header (which, while not common, is possible, and 
can chuff up recipes like the one you have).

This is the stage where you might want to pipe the addresses through your 
"scrubber", whatever you end up developing for that.

       :0fhw
        | formail -I "To: pelletesti(_at_)some(_dot_)com" -I "Cc: $ORIGTO, 
$ORIGCC"
}

Here, you'd use the $NEWCC instead of the ORIGTO and ORIGCC stuff.

:0
* ^TOpelletesti(_at_)some(_dot_)com
! realman(_at_)some(_dot_)com


It does what it is supposed to do. If matching, it will move all
recipient addresses to the Cc: header, add a new To header and send it
to realman(_at_)some(_dot_)com(_dot_)

Why do you need to change the message to have the recipient as the 
plaintext To?  The headers are just for show and needn't be set any 
particular way for the MTA to deliver a message.


        As I explained in a previous mail. M$ CRM. (It really is a pain in the
ass from a mail routing point of view...)  Luckily our frontend mail
servers are linux, where you can "fix" mails to look right for the crm
so that it want break the cases etc...


But this is not enough. What I need now is a way to do the same as
above, but also remove all "toberemoved(_at_)some(_dot_)com" email-addresses 
both
from TO and Cc headers.

Pipe the extracted addresses through sed.

        Yes, but I didn't find a way to remove the mail address cleanly in all
it forms. Ok. This is more a sed expert discussion, but I thought, that
somebody on this lists would have had a similar need and a working
solution. 


The problem is of course, that the "toberemoved(_at_)some(_dot_)com" address 
could
show in many different ways: "To Be Removed" 
<toberemoved(_at_)some(_dot_)com> or
toberemoved(_at_)some(_dot_)com (To Be removed) or whatever.

Indeed.

---
  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 homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

-- 
*** tonyk(_at_)iki(_dot_)fi ***
* Tony K Lindström *
 ******************


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
____________________________________________________________
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

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