procmail
[Top] [All Lists]

Re: Recipe wanted

1998-03-16 13:26:15
At 12:48 PM 3/16/98 -0600, LAURA HENRY wrote:
Can you give me a recipe for procmail v3.11pre7 which will auto-reply to mail
from a specified undesirable sender, saying something like "Your message has
been refused.  Please do not attempt to contact this address again."  and
then
deleting the incoming message so that it never appears in the recipient's
INBOX?


I run my filtering a bit different than this (for one, I don't send replies
to twits - they're a waste of bandwidth), but here is a butchered version
of what I use that should accomplish what you're after.  As usual, the
butchered version is untested and provided as-is.


$FORMAIL, $FGREP, $SENDMAIL are set to the path and executable of
associated programs.
$TWITLIST is a file containing twits you want this to apply to
$AUTOREPLY is the path to your autoreply texts
$MAILBOT is your mail responder address (omit the -I "From: ..." if you
don't have aliases).  I use this to manually direct replies into a separate
bitbucket (generally negating a need to check loops in my case).

You can hardcode any of these values instead of using variables - I just
use them throughout my scripts, and it works easier this way.

Edit the twit.msg file to contain whatever you want to bounce back at the
sender.

If you just want to match against ONE address, replace the initial
(formail/fgrep) condition line with:

* ^From:(_dot_)*twitaddress(_at_)twitdomain

But using this method allows you to easily add multiple twits to the rule
(in my case, I have other rules that allow me to add to the list via mail).

# If the FROM address is matched against our list of twits...

:0
* $? $FORMAIL -xFrom: | $FGREP -i -f $TWITLIST
{
        # The following recipe can be used to auto-reply a twit message
        # to the sender (provided that it is a valid address).
        :0
        * ! ^X-LOOP: yourxloopid(_at_)yourdomain
  | ( $FORMAIL -rt -I "X-LOOP: yourxloopid(_at_)yourdomain" -I "From: $MAILBOT" 
;\
   cat $AUTOREPLY/twit.msg ) | $SENDMAIL -t

        # catch looped messages to trash
        :0
        /dev/null
}

---
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

 Sean B. Straw / Professional Software Engineering
 Post Box 2395 / San Rafael, CA  94912-2395

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