procmail
[Top] [All Lists]

Re: About the magazine spam

1996-04-12 00:35:55
Anyway, with the Internet changing as quickly as it is these days, it
seems to me foolish to have so ubiquitous an MTA as sendmail so
dependent upon "the kindness of strangers".  I would love to be able
to (at minimum) say "if there's no gwu.edu in the From line and no
gwu.edu in the To line, reject it".  That won't stop KrazyKevin if he
ever starts forging our addresses, but if sendmail had that feature it
would have saved me a LOT of headaches and late nights responding to
email complaints over the past few months.

It is not sendmail which is relying on the kindness of strangers, it is
the system manager who has failed to configure it carefully enough.

Sendmail is infinitely configurable, either by modifying its
configuration rules, or by makeing the target addresses be aliases which
filter the mail through programmable filters.

In either case, if you obtain "procmail" you will be able to implement
either pre-delivery filtering or in-delivery filtering, as desired.

Having obtained procmail, you can then use SmartList (which is a mailing
list implementation based on procmail recipe files, and a couple of
binaries).  SmartList gives you control over who can see the lists, who
can subscribe, and who can submit.  If you peruse the procmail archives,
you'll see many solutions for problems similar to yours.

The procmail man pages describe how to modify the sendmail rules (in
sendmail.cf) such that a pre-delivery filtering can be accomplished.  In
addition, procmail can be used as the "Mlocal" (the local delivery)
program, replacing the vendor-supplied one.  

With or without procmail as the "Mlocal" program, personal or
system-wide mail filter can be accomplished with procmail as a "pipe"
filter (ie: "|procmail -m /etc/procmailrcs/register").

This gives you all the "hooks" you need to be able to detect "bad" addresses
and throw any mail from them away, or cause bounce-backs, or whatever
action you choose to take.

For example, suppose the "bad guy" address who has been spamming you
uses the subject "free subscriptions", and typically originates from a
fictious sender of "KrazyKevin".  A very simple filter to throw away
mail matching this description might be:

    :0
    * ^(From|Sender): *KrazyKevin
    * ^Subject:.*free subscriptions
    /dev/null

Any mail which gets past this filter, would then be delivered as usual.

If you wish to bounce rejected mail back with a message:

    :0
    * ^(From|Sender): *KrazyKevin
    * ^Subject:.*free subscriptions
    {
      :0                        # avoid loops
      * ^X-Loop: antispam
      /dev/null

      SUBJ=`formail -zX'Subject:'`
      :0 fh                     # replace the headers
      | formail -rt -I"Subject: Re: $SUBJECT" -I"X-Loop: antispam"
      :0 fb                     # replace the body
      | echo "Sorry, we aren't accepting mail from you regarding" ;\
        echo "this subject for the time being."
      :0                        # send it back & drop the mail
      ! -oi -t
    }

The SmartList mailing list has the ability to insert site-local recipes,
such as the one above, at various processing points.

I have made available a suite of recipe files to ease or guide the
development of personal mail filters based on procmail.  In addition,
you can get my enhancements to SmartList which make remote list
management easier.  Both libraries are available from my home "mail" page:

    http://www.engineering.ucsb.edu/~aks/mail

or by sending me an email with the subject of "send procmail library" or
"send smartlist library".

Good luck.
Alan

<Prev in Thread] Current Thread [Next in Thread>
  • Re: About the magazine spam, Alan Stebbens <=