procmail
[Top] [All Lists]

Re: .forward and procmail

1996-04-18 07:04:49
Kevin Lentin <kevinl(_at_)cs(_dot_)monash(_dot_)edu(_dot_)au> writes:

[mail arrives on multiple machines, wants it delivered on just one]

So my first stab at this was as follows.
I put: HOST=fangorn.cs.monash.edu.au 
in .procmailrc (or HOST=indy03 or whatever the machine in question is).

And I put:
kevinl(_at_)fangorn(_dot_)cs(_dot_)monash(_dot_)edu(_dot_)au,"|IFS=' '&& exec 
/usr/monash/bin/procmail -f-|
|exit 75 #kevinl"

in .forward.
...
My current solution to the problem is ugly. I pipe my mail through a script
that tests which machine it is on. If it is on the wrong machine, it
'encodes' the message by taking the 'From ' line and turning it into an
X-Orig-From: line and piping that to sendmail to deliver it to myself at
the right machine. If it is running on the right machine, it takes an
X-Orig-From: line if it finds it, replaces the 'From ' line it finds (which
always says me since it was forwarded by me in the first incantation of the
script) and pipes that to procmail.


Just put the following recipe at the top of your .procmailrc:

:0
* ! HOST ?? (fangorn\.cs\.monash\.edu\.au|whatever_it_thinks_its_name_is)
{
    # Try to catch mail that we forward but that bounced.  All we can do is
    # save to folder (we don't dare try mailing something)
    :0:
    * ^FROM_MAILER
    * BH ?? $ ^X-Loop: $LOGNAME(_at_)$HOST
    panic_folder

    :0
    |formail -R'From ' X-Orig-From: -I"X-Loop: $LOGNAME(_at_)$HOST" | \
            $SENDMAIL -oi 
kevinl(_at_)fangorn(_dot_)cs(_dot_)monash(_dot_)edu(_dot_)au
}

# The following doesn't work unfortunately, as formail doesn't know that
# a header renamed to 'From ' should be moved to the top.
#:0
#* ^X-Orig-From:
#|formail -I'From ' -RX-Old-From: 'From '

# ...but the following should work.
:0
* ^X-Orig-From: \/.*
|formail -I"From $MATCH"


Philip Guenther

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