[Scottish] procmail - rewrite RHS of email addy

Martin McCarthy scottish at mailman.lug.org.uk
Mon May 26 15:35:01 2003


Sorry for the late reply, I've been elsewhere for a while.

> i also need this to work if my email addy is i the CC field or part of a
> long list of addresses, or (as in a mailing list) the 'To:' field dosn't
> contain my actual email addy.

That simply isn't going to work some of the time.  For example, if
you're a recipient in a Bcc: field.  It's something that the MTA
(sendmail in your case) should do.  If sendmail won't cut it, maybe you
should consider qmail, exim or postfix?

Anyway, if you accept that this won't necessarily work you could try
a recipe like (completely untested, of course):

  # if it's to:, cc:, aparently-to:, etc. the appropriate address
  :0
  * ^TO_matt@testdomain\.com\>
  {

    # make a backup 'c'opy
    :0 c
    backup-mbox

    # modify ('f'ilter) the 'h'eaders and 'w'ait for this to complete
    :0 fhw
    | sed s/matt@testdomain\.com/matt@mail-server.net/g

    # send the modified mail to the other address
    :0
    ! matt@mail-server.net
  }

Hope that makes some sense. 
Martin
-- 
Martin McCarthy                 /</         http://www.non-prophet.org
marty@ancient-scotland.co.uk    \>\  http://www.ancient-scotland.co.uk
                                /</    http://www.ehabitat.demon.co.uk