[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Help with Spam Assassin

Posted on 2009-02-23
Medium Priority
Last Modified: 2013-12-09
I need help with Spam Assassin.

1. What version of Spam Assassin do I have?   I was told that I need to do this through SSH.   I am able to open putty and my spam assassin is installed in this directory:    /.spamassassin/

Please tell me what to type in my putty command line to determine the current version of spam assassin.   If you know of an easier way rather than SSH, please tell me that instead.  :-)

2. How do I update spam assassin?   I read on the apache site that I need to run sa-update, but I need the exact syntax.   My spam assassin folder is called /.spamassassin/

I can get putty to open for root CLI commands.  Please tell me what to type to update sa-update.

3. I also know how to create a cron job.  I think that if sa-update will work as a command line, that I could also enter this as a cron job to run nightly.  Please confirm if I can do this with the same syntax.

4. I read that I can add specific emails to a spam assassin white list via command line.   Can you tell me the syntax to use to add my sent emails to the whitelist?

5. Next Id like to set up the baysean filter.  If you can answer the above questions, you probably know how to do this as well.   I can read the apache instructions, but am wondering if there is a way to do this other than through command line.

Thank you for your help!
Question by:Shawn-in-VA
  • 2
LVL 23

Expert Comment

by:Maciej S
ID: 23727111
1. spamassassin --version
2. If you are using linux, then what distribution? If you are using some other *nix system - then what is it?
3. Yes, you can :) Add below line into your crontab (to run sa-update daily at 1am):
0 1 * * * /path/to/your/sa-update && /etc/init.d/spamassassin reload
You may need to change this /etc/init.d/ path to one that suits your environment
4. Add to your configuration file (for user it is by default ~/.spamassassin/user_prefs) below line:
whitelist_from add@ress.com
5. I don't know other possibilities that command line (I don't say, that there is no such possibility, but I just use commandline). It should be enabled by default.

Author Comment

ID: 23741584
oklit - Thanks for your reply.  

1. your answer worked perfectly.  I have spam assassin 3.2.4 and perl 5.8.8

2. How do I update spam assassin?   I'm running linux, apache 2.2.11.  I went to the spamassassin faq area and found this sa-update syntax:
sa-update && service spamassassin restart

This appears to work, but can you tell me how to confirm that it actually is working?   When I enter that into my putty command line, the system accepts the command and returns a new command line with no message about what it did.  

3. for an update cron job, you suggested this:
0 1 * * * /path/to/your/sa-update && /etc/init.d/spamassassin reload

Regarding #3, i have a few questions:
- can I test this syntax in putty or is this specific to a cron job?

- what is the path to sa-update?  I could not find it?   Also I could not find Init.d/spamassassin.

Please try and reply with the exact syntax to use (or ask me for more path info and I'll look to confirm the exact paths).  

4. you answered great.  thanks.

5. I'll use the command line if i have to, but can you tell me how to better train it when it does not identify spam correctly.  

Thanks for your help!
LVL 23

Accepted Solution

Maciej S earned 2000 total points
ID: 23743076
2. I don't use sa-update (probably I should, but didn't have to for now - spam is recognized correctly, and I use almost the same configuration, since installing it - it is something about 4 year now).
Moreover - I misunderstood your question. I thought you meant to upgrade spamassassin, not update - that's why I asked for distribution :)
In most cases it should be enough to run just "sa-update" command without any parameters (but you need to run this as root).

3. In crontab, you should provide full paths to binaries. TO check where is your sa-update located, login, and run: "which sa-update". You will probably get /usr/bin/sa-update or similar. Use full path (/usr/bin/sa-update, or whatever output you get) in crontab.
If you are running spamassassin as daemon, you should restart it after updating. /etc/init.d/spamassassin is script to start/stop/restart/reload spamassassin's daemon. Do you have /etc/init.d/ directory? Do you have spamassassin file inside this directory? If no - what distribution you have? Maybe you have /etc/rc.d/ or similar in which this script is located. But - if you don't run spamassassin as deamon (spamd) you probably don't need to reload/restart it, so sa-update without /../../spamassassin reload should be enough.
Finally - of course you can test it in commandline. Crontab entries are in fact commandline command.
command1 && command2 means: run command2 only if command1 finished successfully.
If "service spamassassin restart" works for you, then use it instead of directly calling /etc/init.d/spamassassin.
So, crontab entry should be:
0 1 * * * /usr/bin/sa-update && /usr/bin/service spamassassin reload
(in case you have this files in other places, change paths accordingly - you may check them typing: "which sa-update service").

5. Use "sa-learn". You can point sa-learn to mailbox with spam (sa-learn --spam /path/to/mailbox/with/spam). You need also to learn spamassassin what is not spam (what is ham): sa-learn --ham /path/to/mailbox/with/ham
Refer to man sa-learn (or sa-learn --help) for more options.
More than this - you may also create your own rules. To add some rule for specific user, edit his/her ~/.spamassassin/user_prefs file. If you want to add rules for all users, edit your local.cf file. You can find example of creating your own rules in spamassassin here: http:/Q_24144658.html

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Encryption for Business Encryption (https://en.wikipedia.org/wiki/Encryption) ensures the safety of our data when sending emails. In most cases, to read an encrypted email you must enter a secret key that will enable you to decrypt the email. T…
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question