Spam filtering on Plesk – don't buy it!
So I decided I would give up shared hosting for good and instead run a VPS based Linux instance with Plesk to help me setup web sites and mail accounts for a few of my domains. The license fee seemed to be well worth the money. Plesk brings a whole lot of power into one comprehensive web interface which saves me huge amounts of time and trouble compared to doing everything manually.
But I was rather disappointed when I realized that such a fundamental puzzle piece as a spam filter wasn't included in my license. Here's why I think that sucks and how I worked around the problem – twice.
Plesk and open source
My Plesk installation on Ubuntu actually has the spam filtering program Spamassasin included on the server, only the spam options in the Plesk interface are grayed out. You keep looking for the On switch, only there isn't one. Oh, I need to purchase the "Power pack"? Nice.
Same goes for a few other applications that are installed but not enabled, such as PostgreSQL and Tomcat. I don't need those however so that's not an actual problem in my case. (I actually uninstalled those to save some resources.)
So why is this wrong? Well, Plesk at it's core is a bundle of free, open source software. What you pay for is the web interface and support. Of course, nothing can stop Parallells, which owns Plesk, from enabling and disabling features in their interface all they want, but why not being generous about these things? After all, they're making money on software they didn't pay for (which is fine since it's open source). Had I known of this I would probably have gone for something like ISPConfig instead.
Now, enough picking on Plesk. After some research I found a very easy solution to the problem, although not as user friendly or feature complete as the Plesk solution (or so I assume). Being a little unsatisfied with the result though, I ended up using a different approach. (More about that below.)
Quick and dirty: .qmail files
Here's what you do: For each new mail account, find the corresponding account directory: /var/qmail/mailnames/{domain_part}/{user_name_part}/. In that directory you will find the magic .qmail file. I won't go into any details about Qmail or Spamassassin here, but by making the following small change to that file – marked with bold type – all email coming into that account will be processed by Spamassassin.
| true
| /usr/bin/spamassassin | /usr/bin/deliverquota ./Maildir
Spamassasin will check the messages and tag them with the appropriate mail headers. It won't block spam messages with this setup, so your users need to setup their mail clients so that they filter their incoming messages according to the spam headers. There is also a .spamassassin directory created within the same directory. It can be used to tweak the Spamassassin settings for this mail account. (You can make Spamassassin reject spam messages, but that requires dealing with stuff that is more intimately connected with Plesk's implementation of Qmail, which I'd rather avoid.)
If someone wants to go further with this approach, you could take a look at Plesk's event handler and see if you can create a script which changes the .qmail files automatically each time a new mail account is created. Shouldn't be too hard I think.
Quick and… clean: Spamdyke
Well, kind of quick anyway. Like I said, I ended up using a different solution than the one described above. Spamdyke is an application that acts as a filter between connecting SMTP servers and Qmail. The big benefit is that you keep your Qmail installation and configuration intact – you don't need to touch anything in Plesk's Qmail setup. You'll need to compile Spamdyke however – there are no deb or rpm packages available as far as I know – but that's actually very quick and easy.
You can follow Spamdyke's installation instructions or use these Plesk specific instructions. (Note that in the latter instructions they forgot to touch /var/qmail/spamdyke/never_greylist. There's also some potential confusion between "gray" and "grey" so make sure you don't make a mistake there.) These instructions in German look great too – if you know German.
One thing I was having trouble with was finding the right spot to insert the Spamdyke command. It turned out that I should put it in /etc/inetd.conf (on Ubuntu 6.06 LTS). This is my smtp line (wrapped) with the change marked with bold type:
smtp stream tcp nowait.1000 root /var/qmail/bin/tcp-env tcp-env /usr/bin/env SMTPAUTH=1 END=1 /var/qmail/bin/relaylock /usr/local/bin/spamdyke -f /etc/spamdyke.conf /var/qmail/bin/qmail-smtpd /var/qmail/bin/smtp_auth /var/qmail/bin/true /var/qmail/bin/cmd5checkpw /var/qmail/bin/true
When your're done installing, take some time to read through Spamdyke's documentation and learn all about graylists and other features that can eliminate your spam almost entirely. If you're concerned about graylists stopping legitimate email, you may want to look for lists of ip adresses of mail servers that are known to have issues with graylisting. Here is one.
The Plesk specific instructions I mentioned also describes how to setup a Plesk event handler to automatically setup graylisting for new domains. I never got that to work though.
All in all everything has run smoothly so far – with almost no spam whatsoever. I'm using rather aggressive settings based on what was provided in the instructions. Occasionally legitimate email does get stuck in the filter. The one problem I have seen is email servers not having a rDNS record. Another issue is that graylisting can be a problem if you're in a hurry, because it sometimes delays emails up to an hour or more.



Kommentarer
Skriv ny kommentar