Turning On Spam Checks with Script

Julian Field mailscanner at ecs.soton.ac.uk
Wed May 7 08:48:01 IST 2003

At 18:47 06/05/2003, you wrote:
>What I would like to do is setup Mailscanner so it does Spam checks but all
>users are whitelisted by default.  So if they want Spam checks they must
>turn it on and they will have no reason to complain to me about seeing there
>email tagged with {SPAM?}.
>To explain.  If a user wants Spam checks enabled on there email account they
>would go to a webpage, enter there email address in a form and that would
>enable Spam checks for them.  If they later decide they do not like getting
>a bunch of there email tagged with {SPAM?} they could go back and enter
>there email in a removal form and turn it off.  It would also be nice if
>they could enter a from addresses to whitelist in a form if its being tagged
>incorrectly.  All these forms should have access restricted to local IP
>subnets I control for security.
>Is something like this possible with a perl script?  I imagine one gotcha is
>that if a config file is modified by a script it will not take affect until
>mailscanner is restarted but that occurs every 6 hours I thought?

What I would do is turn on and off their {SPAM?} Subject: line tag, not the
actual spam checking. Then if a "power user" wants to do his/her own
filtering on the SpamScore header (for example) but doesn't want the
Subject: line tag, then they can do it.

How you the implement it depends on how many users you are talking about.
If it's only a few hundred or so, I would recommend rebuilding a
"spam.modify.subject.rules" file which is pointed to by an entry in
MailScanner.conf like this:
Spam Modify Subject = /etc/MailScanner/rules/spam.modify.subject.rules

Then make that file say
FromOrTo:       default         no
To:             user1 at domain.com        yes
To:             user2 at domain.com        yes
and so on.

If you are talking thousands of users, a database table might be better.
You can suck in the DB table when MailScanner starts, then just do a very
fast hash table lookup for each message. This will be very quick. If you
have a "semaphore flag" file somewhere that indicates if the DB table has
been modified recently, and a cron job to "reload" MailScanner, you can
restart it every hour or so if any users have modified their settings.
Julian Field
MailScanner thanks transtec Computers for their support

More information about the MailScanner mailing list