SpamAssassin for Dreamhost
The revised guide for versions 2.61 and above has been posted.
First off, this article applies only to Dreamhost users that have a shell account. You need a shell account because there is some required UNIX scripting. The whole process took me about an hour last night but since I already took the plunge, it should only take five minutes or so for you to set SpamAssassin after having read my guide.
Richard Donkin originally posted a SpamAssassin for Dreamhost guide but it’s a little outdated. It sure helped me with the installation though. I figured I’d update the guide a little bit since at the time of this post, the current version of SpamAssassin is 2.55 — Richard’s guide covers version 2.20.
First, head over to the SpamAssassin download page. Download the latest stable release in tar.gz format. Log on to your web server and upload this folder to the root directory in BINARY format. The root directory should have some folders like Maildir, logs, etc. If you don’t have a Maildir folder, Dreamhost has a kbase post for you!
Next, download Richard’s SpamAssassin setup tar and upload it to the root folder in BINARY.
Now you’re ready to do a little bit of UNIX scripting. Make sure you have a decent telnet/SSH client — I use PuTTY. Connect to your web site via SSH (you can also use Telnet). Type the following command (make sure the file name is correct):
tar xvfz Mail-SpamAssassin-2.55.tar.gz tar xvfz spamassassin-setup.tar.gz
Check to make sure that the folders Mail-SpamAssassin-2.55 and spamassassin-setup are present in your root directory. If not, you didn’t untar the files correctly. If you can’t figure it out, I suggest praying to Google or e-mailing me.
Next, you have to install SpamAssassin in your account. Type the following, one line at a time:
cd ~/Mail-SpamAssassin-2.55 perl Makefile.PL PREFIX=~/sausr SYSCONFDIR=~/saetc make make install
You should notice the server processing a lot of files after make and make install. Don’t worry, you didn’t break anything. Actually, Dreamhost encourages you to install your own version of SpamAssassin. Check and make sure the directories saetc and sausr are present in the root directory.
Now you can move the Mail-SpamAssassin-2.55 folder. Create a folder in the root called lib. Move Mail-SpamAssassin-2.55 into the lib folder.
Next, you have to create a symbolic link to the SpamAssassin directory. In your SSH client, type:
ln -s ~/lib/Mail-SpamAssassin-2.55 ~/lib/SpamAssassin
Finally, you have to transfer Richard’s spamassassin setup files. Make two more folders in your root directory: .spamassassin and procmail. Move the .rc files into the procmail folder and the user_prefs file into the .spamassassin folder. Move the .forward.postfix and .procmailrc files to the root. If there is an existing .procmailrc file, back it up and replace it with the new one.
Send yourself a test mail and a test spam. Check the procmail log, located in ~/procmail/log. You should get output here. Also, check and make sure the SpamAssassin headers appear in your e-mail — just use SquirrelMail and check the message header.
At the time of this post, Richard’s spam.rc needed modifying. Edit the file and get rid of the -P flag. Dreamhost doesn’t allow that any more.
SpamAssassin should be all set up and ready to go. Enjoy! It works a lot better than Razor. I’ve used SpamAssassin for my UCLA e-mail for two years and it catches about 99 percent of spam, without trashing valid e-mails.
21 comments
(5 years, 9 months ago)
I followed your extremely helpful instructions for setting up SpamAssassin on my Dreamhost account, but it does not appear to be working correctly. When I checked the procmail log, I saw these messages:
Any ideas on what might be causing this and what I can do to fix it? In addition, once it is working, what can I expect? I have been using Razor; does Spam Assassin work similarly by putting spam in a separate folder?
Thanks!
(5 years, 9 months ago)
Ok, I reinstalled it and now it seems to be working (i.e., I see SpamAssassin info in the header and the log files don’t reflect any errors). But I’m still confused about how SpamAssassin handles the spam – does it delete it, do I have to create a folder for it?
Thanks!
(5 years, 9 months ago)
SpamAssassin moves it into a Spam folder like Razor, at least that’s the way I set it up in the instructions on the site. If you go into SquirrelMail, there is a link at the very top of the right column that says Folders. Click on that and under Unsubscribe/Subscribe there should be a folder on the right that says Spam. This folder will only be present if there has been a Spam message sent to you. The other way you can check is to log onto your web space via FTP, go to Maildir then .Spam then new. You can check your message log as well in the procmail folder and when you get a spam, it will indicate where the Spam has been moved. But no, it doesn’t delete the messages because that would be bad — I’ve gotten a couple of false positives from AOL users without real names entered in to the “To:” field in the e-mail.
(5 years, 9 months ago)
Thanks for the input. It seems to be working now :)
(5 years, 9 months ago)
Thanks for the instructions. Do you know how I can install SpamAssassin for a user who has a mailbox but not a shell account on my domain hosted by Dreamhost?
(5 years, 9 months ago)
I also followed these directions to install SpamAssassin 2.60. Things seemed to work for a while, but when I looked in my procmail log file I saw a whole bunch of error messages for each piece of mail that was sent to SpamAssassin — mostly “Failed to run … SpamAssassin test” messages with the same explanation:
... (perhaps you forgot to load "Mail::SpamAssassin::PerMsgStatus"?) at ~/lib/SpamAssassin/lib/Mail/SpamAssassin/PerMsgStatus.pm line 2219This seemed odd, so I did a little investigation. I finally changed the invocation line from “spamassassin.raw” (which looks like it’s supposed to be an input file for the configuration/installation process) to “spamassassin”, and the errors went away. At the same time, the form of the notice inserted by SpamAssassin at the head of spam messages changed, from the familiar “This mail is probably spam” to one beginning:
Spam detection software, running on the system "hostname.dreamhost.com", has identified this incoming email as possible spam. ...I found this latter text in the rule file 10misc.cf in my local installation. The original text could only be found in the system-wide installation, at /etc/spamassassin/10misc.cf. Apparently when spamassassin.raw failed to find certain files it fell back on a global version. (I don’t know Perl so I couldn’t pursue this.)
My question, then, is why do your directions suggest running spamassassin.raw? (And am I correct in changing it to plain spamassassin?)
(5 years, 9 months ago)
Zack: The user account must be a shell account to install SpamAssassin. However, you can use Razor with Dreamhost mailbox accounts.
Russell: It looks like there is some problem with your configuration path. The path in the spamassassin.raw output looks strange to me:
~/lib/SpamAssassin/lib/Mail/SpamAssassin/PerMsgStatus.pmSee how the /lib/SpamAssassin part is duplicated? Did you set up the program that way?
Also, if you are correct about invoking Dreamhost’s global SpamAssassin install with spamassassin instead of spamassassin.raw. However, their version is very old and unsupported, since they now use Razor. spamassassin.raw is indeed the file you want to call up. However, there may have been some program tweaks with SpamAssassin 2.60. I’m not sure what they did because I’m still running 2.55. I’ll try installing 2.60 and see how it goes. I’ll see if I can generate the same error. It’s possible that I need to modify some of Richard’s files.
(5 years, 9 months ago)
I installed SpamAssassin 2.60 on my DH account by following the instructions in the SA INSTALL file and it seems to be working fine. I did not do anything with a ~/lib directory or symbolic linking and I’m wondering if that’s necessary?
BTW, I just updated my IMAP Service Providers page and added a link to this article in the DreamHost section, which is here:
http://www.ii.com/internet/messaging/imap/isps/#DH
Thanks for your article and this discussion, Nancy
(5 years, 9 months ago)
A couple more comments: I’m writing about my SpamAssassin and Procmail configurations here and here
Both of these are works in progress, but these are basically the configs that I’m currently using on my DH account.
(5 years, 9 months ago)
Mike: I just installed 2.60 and I am getting similar errors to Russell.
(5 years, 9 months ago)
BTW the path that Russell had in his error exists and that file is there.
(5 years, 9 months ago)
Hmm, the razor2 thing is the Dreamhost mail filter that comes preinstalled on the server. Could you e-mail me the modified spam.rc file (my e-mail address is listed on the e-mail page).
(5 years, 9 months ago)
A lot of my email is routed through my old ISP and to my DH account where I now do my mail filtering, delivery, and storage. During the fiasco this week when the dreamhost.com domain name was hijacked by VeriSign because it wasn’t renewed (!!), I changed my email routing so it was filtered and delivered on my old ISP account. I set up virussnag 1.3 and spamassassin 2.60 and in the process discovered a few things: 1) I need to clarify some of the things that I’ve written on my web site about setting up this stuff and 2) I got a lot less false positives on my old ISP account! My old ISP has neither razor2 nor the Net::DNS perl module installed so now I’m trying to figure out how to improve my SA scores on DH. For the moment I’m not using razor2 by putting this in my user_prefs file:
use_razor2 0
I’d also like to experiment with the various RBLs. If anyone has any suggestions for which RBLs to use or not use, please post. Also, if you get better or worse scores with razor2, please post that too.
Thanks, Nancy
(5 years, 9 months ago)
Sorry for so many comments, but the spam.rc file is definitely wrong. spamassassin.raw is the uninstalled version of the program. The correct installed version is ~/sausr/local/bin/spamassassin. I used that and the errors in the log have gone away except for:
razor2 check skipped: Bad file descriptor Insecure dependency in connect while running with -T switch at /usr/lib/perl/5.6.1/IO/Socket.pm line 108.Any ideas?
(5 years, 9 months ago)
Thanks for the great article, but I am also struggling with the errors above when installing 2.60. I will try some of the suggestions.
Regarding the Razor2 problems, I noticed the following FAQ entry:
Now, I’m too much a noob to tell if that is what the problem is, but I wanted to point it out.
(5 years, 8 months ago)
followed the instructions (modulo using 2.60). does not appear to work. there is no “procmail” dir in my root, so no log to inspect. is it necessary to install procmail locally first, or?
(5 years, 8 months ago)
please disregard my post above. i’ve worked it out RTFM-style. next to set the threshold higher…
(5 years, 8 months ago)
Your procedures do not work with v2.60
(5 years, 8 months ago)
I’ve gotten spamassassin to work using the generic .forward file:
Using the .procmail.postfix does not work with version 2.60. In fact, a generic SA install works fine with dreamhost and version 2.60. Why is there a specific dreamhost configuration blog?
(5 years, 7 months ago)
Just a note – the “-P” option to spamassassin was required with earlier versions of SA, including the one that’s still installed on the customer mail machines. It’s not required if you are using a later version.
A couple comments about the last message – unless you’re using a duplicate filter, just “|/usr/bin/procmail -t” should be fine. The file is “.forward.postfix”, not “.procmail.postfix”. Just using “.forward” won’t work (this is for historical reasons – .forward works on the user machines, and .forward.postfix works on the mail machines).
(5 years, 6 months ago)
Discussion is closed on this entry because an updated guide has been posted.