At 13:07 2001-12-19 -0500, Max wrote:
I have a small project to do, where i have to write a procmail filter so
that when an email arrives to something(_at_)domain(_dot_)com it gets copied to
user1(_at_)domain(_dot_)com
(assuming something(_at_)domain(_dot_)com is the _ONLY_ recipient at the local
mailbox)
:0c
* some condition which makes you decide to forward
* ! ^FROM_DAEMON
* ! ^X-Loop: dont_hose_me(_at_)example\(_dot_)com
{
:0f
| formail -A "X-Loop: dont_hose_me(_at_)example(_dot_)com"
:0
!user1(_at_)domain(_dot_)com
}
and then From filed has to be changed on the original
email and it has to be sent to user2(_at_)domain(_dot_)com (so user2 doesnt know
where the mail came from, but user1 does).
Newsflash: there are _MANY_ things which can identify the origin of the
message - the messageid, the received lines, optional headers, and the body
(incl. .sig) itself.
:0Ac
{
:0f
| formail -A "X-Loop: dont_hose_me(_at_)example(_dot_)com" \
-I "From: sloth(_at_)domain(_dot_)com"
:0
!user2(_at_)domain(_dot_)com
}
If you don't want a copy to continue to be delivered to the original
recipient, remove the 'c' from the above. If a forward bounces, the
FROM_DAEMON (which you might want to change to FROM_MAILER, a matter of
preference, see the man pages), or gets autoforwarded back to you (a mail
loop), the X-Loop check, should keep you from endlessly forwarding
them. Of course, _regular_ bounces won't be forwarded either.
As per .sig, this is untested - I suggest you look back a few days in the
archives of this forum for a script I wrote for doing sandbox testing with
forwards by redefining $SENDMAIL to point to a shell script. This will
save you - and the hapless victims you're forwarding these messages to - a
LOT of grief while testing your script. Date was 11 DEC 2001, subject
"Testing filters before putting them into live use".
I never touched procmail before,
Tread carefully then - misuse of it can easily ruin people's days if you
cause mail loops. If you ruin someone else's day, they might choose to
ruin yours (say, a sysadmin who kindly dumps your mail to /dev/null to get
the loop to stop).
and after few hours of digging through its (as well as regexp)
manuals, i wrote something that gets the job half way done.
.. which I didn't even look at, because you sent it to a mailing list as an
ATTACHMENT.
---
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(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail