How to MailScanner SpamAssassin Spambox

bmcgrail

Well-Known Member
Dec 8, 2003
83
0
156
I wanted to run spamassassin on my system from MailScanner. When I tured this on both MailScanner was running spamassassin and so was exim.

Here is what I changed on my system to allow spamassasin to be run from MailScanner while still keeping the use of the spambox for domains that want it.

For the scope of this I am not going to go into how to configure MailScanner or the Exim in/out queues.

First I setup MailScanner and told it to check for spam and use spamassassin.

Then I shut off spamd in my startup scripts. (touch /etc/spamdisable)

Next I edited /etc/exim.pl so it would find the correct headers and route the spam. I am sure that cpanel will over write this next time exim updates so beware.

In exim.pl find the subroutines checkuserspambox & check_deliver_spam
and change
if ($headers =~ /^X-Spam-Status: Yes/m) {
to
if ($headers =~ /^X-MailScanner-SpamCheck: spam/m) {

After doing this everything was working great. However I noticed MailScanner was running twice against locally delivered messages. Not only does this put extra load on the server, it also puts the spam score headers in twice. Very annoying.

To defeat this I edited /etc/exim_outgoing.conf
Commenting out or removing the directors
virtual_sa_user:
sa_localuser:
keeps exim from trying to reinject the message and stops the MailScanner from running a second time.

You can also remove the transports
virtual_sa_userdelivery:
local_sa_delivery:
as they will not be called anymore.

Remember always make copies of your working config files before you edit them :)
 

goodmove

Well-Known Member
May 12, 2003
643
4
168
bmcgrail, what are the benefits (or advantages) of using spamassassin from mailscanner instead of exim?
 

bmcgrail

Well-Known Member
Dec 8, 2003
83
0
156
SpamAssassin Run from MailScanner

Originally posted by goodmove
bmcgrail, what are the benefits (or advantages) of using spamassassin from mailscanner instead of exim?
By default cpanel/exim only runs SpamAssassin against each locally delivered message. By running it through MailScanner, SpamAssassin is run against all incoming messages. And MailScanner runs against a batch which should be faster and less of a load on high traffic email servers.

By running SpamAssassin from MailScanner you can do spam filtering for domains that are not locally delivered. Either as a gateway service or for forwarded messages.

You can also setup rules for MailScanner to treat different email aliases differently.

Lets say you have [email protected], [email protected] and [email protected] for email addresses and they all forward to [email protected]. You can setup rules in MailScanner to change the subject line for spam messages sent to the 1st alias, delete spam sent to the 2nd alias, strip html sent to the 3rd alias and not even scan for messages sent to the realname or any combination.

Note that you do loose the virtual domain user preferences as found in ~./spamassassin/user_prefs (the file that is configured via cpanel > spam assassin > configure spam assassin) However though manual configuration you gain much more control.

--Ben
 

goodmove

Well-Known Member
May 12, 2003
643
4
168
Which virus definition file do you advise to use? Is Clam appropriate for this setup (I believe that's the one that comes with the layer1/mailscanner package)?
 
Last edited: