procmail
[Top] [All Lists]

Re: Removing an address from To & Cc headers. (SOLVED, kind of)

2010-01-21 01:54:09
Ok,

So I now have a working solution, thought it may be good to share it on
the list even if it may be somewhat clumsy. I know it could be done with
sed or perl also, but I decided to use awk. 



In the .procmailrc:

:0
* ^TO(testipelle|kestipelle|toberemoved)
{
        NEWCC=`(formail -c -xTo: -xCc:|tr -s '\n' ','| awk -f 
/path/to/removeaddress.awk)`

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

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


An the removeaddress.awk:

BEGIN {
      FS=","
}
{ 
  $0 = tolower($0)
  for ( i=1; i<=NF; i++ ) 
  if ($i ~ /.*toberemoved.*/ ) 
  { $i ="" }
}
{ 
  OFS=","
  sub(",$","",$0) 
  sub(",, ",", ",$0) 
  sub("^, ","",$0) 
  print $0 
}





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