[Scottish] procmail - rewrite RHS of email addy
Colin McKinnon
scottish at mailman.lug.org.uk
Thu May 8 22:24:00 2003
Matt Lowe wrote:
>Hi, does anyone know if the following is possible with procmail?
>
>mail comes in and gets passed to procmail
>procmail backs up all mail (this bit i got ok!)
>procmail then rewrites the RHS of the email addy, and sends the message
>onto another domain.
>
>e.g.
>mail sent to matt@testdomain.com
>this gets backed upto a local mbox on the mail server
>mail then gets forwarded to matt@mail-server.net
>(without altering any other headers/message body!)
>Sendmail can change the email to matt@mail-server.net
>but does not allow for any kind of local mail backup :(
>
>
...by default no, sendmail won't - but you can configure it to do all
sorts of things (most of them stupid and incomprehensible though). I'd
certainly go with using procmail to do this. It should be a
dawdle.....thinks....(who's the guy on the list who knows everything
about procmail?).
Without wishing to embarass myself too much...something like:
:0
mailbackup
:0
! ${LOGNAME}@mail-server.net
might work.
Or even more tersely, make the forward operation a 'non-delivering' recipe:
:0 c
!${LOGNAME}@mail-server.net
(which has the advantage that everything will be 'backed up' to the
default mailbox instead of a nominated folder in the previous example).
Or for a more funky script (plaguerizing the procmailex man page):
:0
*TOscottish@mailman.lug.org.uk
{
:0
slugbackup
:0
! ${LOGNAME}@mail-server.net
:0 ic
| cd slugbackup && rm -f dummy `ls -t msg.* | sed -e 1,32d`
}
would only forward mail sent to the slug list, and only keep the last 32
messages.
>The reason for this is I want to use a local machine as a mail server,
>but cant afford to lose any emails (am going to play with spam
>filters/mail scanning etc.). So i want the emails to be backed up, but
>also have it sent to mail local mail server (with no apparent changes to
>the headers/body except the change to the RHS)
>
Do you want to change the headers rather than the envelope recipient?
That makes it a lot more complicated!
>
>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.
>
Check the headers of this message - you don't appear in any of them
(except maybe a 'revd for').
Colin