SpamAssassin Installed in 10 minutes.

The easiest way to install third parties software on FreeBSD is to install from the ports. This can't be any easier: become root, go to the directory of the software you want to install and type make install. That's all! Your software is installed. The Makefile takes care of everything. From fetching the source and the patches, to installing it into the right place. You are then ready to use your new installed software.

Install


In our example, we are going to install SpamAssassin from the ports. This example is suitable for a small company with up to a few dozen mailboxes.
# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make config

# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make config

The make config command will present you with a screen like below, where you can choose the SpamAssassin options you want to install.

Some of the options are already selected by default, leave them untouched. Just make sure to select the following ones.

  • SACOMPILE is used to improve SpamAssassin's performance.
  • GNUPG is used by sa-update to fetch the latest versions of the SpamAssassin's rules.

SACOMPILE is an important option to improve SA's performance. I ran quick tests on one of my servers. Without the rules compiled, SA takes an average of 5.4 seconds to process the messages. With compiled rules the messages are processed in an average of 3.6 seconds.

Your screen should now look like this:
http://fred.velvnet.com/sa-config.png


Now that you have configured the options you want for SpamAssassin, you can build and install the software.

# make install
...

# make install
...

At this point, SpamAssassin should be installed, but check your terminal for any errors.

Configure


SpamAssassin's configuration files are all located in the directory /usr/local/etc/mail/spamassassin. The installation process creates a sample configuration file. Just use this file as a starting point for your configuration.

# cd /usr/local/etc/mail/spamassassin
# cp local.cf.sample local.cf
# vi local.cf

# cd /usr/local/etc/mail/spamassassin
# cp local.cf.sample local.cf
# vi local.cf


Here are the lines you want to comment out of your configuration file.
#   Set which networks or hosts are considered 'trusted' by your mail
#   server (i.e. not spammers)
#
trusted_networks 172.16.1.
...
#   Set the file-locking method (flock is not safe over NFS, but it is faster)
#
lock_method flock
...
#   Set headers which may provide inappropriate cues to the Bayesian
#   classifier
#
bayes_ignore_header X-Bogosity
bayes_ignore_header X-Spam-Flag
bayes_ignore_header X-Spam-Status
...

# Set which networks or hosts are considered 'trusted' by your mail
# server (i.e. not spammers)
#
trusted_networks 172.16.1.
...
# Set the file-locking method (flock is not safe over NFS, but it is faster)
#
lock_method flock
...
# Set headers which may provide inappropriate cues to the Bayesian
# classifier
#
bayes_ignore_header X-Bogosity
bayes_ignore_header X-Spam-Flag
bayes_ignore_header X-Spam-Status
...


  • trusted_networks You indicate the IP address of your network. We suppose that you are not sending spam to your co-workers or friends. There is no need to process the mail you are sending.
  • lock_method flock The comment says it all. SpamAssassin is faster when not using NFS. If you are not using a remote file system you should consider commenting out this option.
  • bayes_ignore_header Use the keyword to ignore some of the headers in the bayesian filter. Some spammers include fake well-known headers to try to mislead the bayesian filters.


You are almost done with the configuration. Before you start your anti-spam software, you should get the latest version of the rules and compile them. As we describe it, compiled rules improve performance. The first time you start sa-update you can use the flag --nogpg. You have not installed the GPG key on your system yet. This will allow sa-update to get and install the new rules as well as the GPG key. Next time you run sa-update you will not need that flag since your system will have the keys installed.
# sa-update -nogpg -D --channel updates.spamassassin.org
... 
# sa-compile
...

# sa-update -nogpg -D --channel updates.spamassassin.org
...
# sa-compile
...

You are now ready to run SpamAssassin

Start spamd


Your anti-spam software is now installed and configured. You just need to start its daemon.

The first thing is to tell BSD auto-reboot command script utility (rc) that it needs to start the daemon when it boots. For that, simply add the variable spamd_enable="YES" in your /etc/rc.conf file
# vi /etc/rc.conf
...
spamd_enable="YES"
...

# vi /etc/rc.conf
...
spamd_enable="YES"
...


Next time your systems reboots, the SpamAssassin daemon spamd will be started automatically.

Everything is now ready. Just type the following command to start the daemon
# /usr/local/etc/rc.d/sa-spamd start

# /usr/local/etc/rc.d/sa-spamd start


You can test if everything works fine by sending an email to the daemon. You can use the command spamc for that.
$ cat ~fred/mailtest.eml | spamc
From akstcadsourcemediamnsdgs@adsourcemedia.com Sun Mar 23 10:00:47 2008
X-Spam-Flag: YES
X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on pspec.kascorp.com
X-Spam-Level: ***********************
X-Spam-Status: Yes, score=23.4 required=5.0 tests=INVALID_DATE,
	RAZOR2_CF_RANGE_51_100,RAZOR2_CF_RANGE_E4_51_100,RAZOR2_CF_RANGE_E8_51_100,
	RAZOR2_CHECK,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_XBL,SPF_SOFTFAIL,URIBL_AB_SURBL,
	URIBL_BLACK,URIBL_JP_SURBL,URIBL_OB_SURBL,URIBL_RHS_DOB,URIBL_SC_SURBL
	autolearn=failed version=3.2.4
X-Spam-Report: 
	*  1.7 INVALID_DATE Invalid Date: header (not RFC 2822)
	*  2.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net
	*      [Blocked - see <http://www.spamcop.net/bl.shtml?78.191.143.59>]
...

$ cat ~fred/mailtest.eml | spamc
From akstcadsourcemediamnsdgs@adsourcemedia.com Sun Mar 23 10:00:47 2008
X-Spam-Flag: YES
X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on pspec.kascorp.com
X-Spam-Level: ***********************
X-Spam-Status: Yes, score=23.4 required=5.0 tests=INVALID_DATE,
RAZOR2_CF_RANGE_51_100,RAZOR2_CF_RANGE_E4_51_100,RAZOR2_CF_RANGE_E8_51_100,
RAZOR2_CHECK,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_XBL,SPF_SOFTFAIL,URIBL_AB_SURBL,
URIBL_BLACK,URIBL_JP_SURBL,URIBL_OB_SURBL,URIBL_RHS_DOB,URIBL_SC_SURBL
autolearn=failed version=3.2.4
X-Spam-Report:
* 1.7 INVALID_DATE Invalid Date: header (not RFC 2822)
* 2.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net
* [Blocked - see <http://www.spamcop.net/bl.shtml?78.191.143.59>]
...


As you can see, SpamAssassin adds a few headers in your mail as a result of processing. The fields X-Spam-Flag, X-Spam-Level are the ones you are going to use to filter the spam either in your Mail Transfer Agent (MTA) or in the mail software you are using every day to read your email.

Using SpamAssassin


Now that you have SpanAssassin installed, you need to send your incoming email through it. You can configure your MTA (Mail Transfer Agent) to use SpamAssassin as a filter, or use the procmail program to tag the email before it is saved into your INBOX.

Using your MTA to filter the spam

You can add the following rule to your exim configuration file. This rule will tag all the emails as spam or not spam.

acl_check_data:

  warn  message = X-Spam-Score: $spam_score ($spam_bar)
        spam = mailnull:true
  warn  message = X-Spam-Report: $spam_report
        spam = mailnull:true

  deny message = Spam score too high ($spam_score)
        spam = mailnull:true
        condition = ${if >{$spam_score_int}{150}{1}{0}}

acl_check_data:

warn message = X-Spam-Score: $spam_score ($spam_bar)
spam = mailnull:true
warn message = X-Spam-Report: $spam_report
spam = mailnull:true

deny message = Spam score too high ($spam_score)
spam = mailnull:true
condition = ${if >{$spam_score_int}{150}{1}{0}}


With this exim rule, all the messages with a spam_score higher than 15.0 will be automatically rejected. But all other emails will go thru with their tags spam or not spam. You can use your mail software to filter these potential spams. Here is an example of a rule you can use in the Mac OS Mail.app. This rule will send all the emails tagged as spam to your Junk folder.

http://fred.velvnet.com/SpamRule.png


Using procmail to filter your mail

You need to create a .forward into your home directory as shows below. This will tell your MTA to filter your mail using procmail.
"|IFS=' ' && exec /usr/bin/procmail -f- || exit 75 #user"

"|IFS=' ' && exec /usr/bin/procmail -f- || exit 75 #user"


Add the following rules to your .procmailrc file, located in your home directory.

:0fw: spamc.lock
| /path/to/spamc

:0:
* ^X-Spam-Status: Yes
spambox

:0fw: spamc.lock
| /path/to/spamc

:0:
* ^X-Spam-Status: Yes
spambox


The first rule will send the mail thru SpamAssassin, The second rule will catch all the messages with the field X-Spam-Status set to YES, and save them into the folder spambox.

Administration


There is not a lot to do to administer SpamAssassin. You just need to watch once in a while the log files to check if everything goes as expected. You also need to update the rules. Once every week seems reasonable. You can write a simple shell script to do the updates and compile.
#!/usr/bin/sh
#
sa-update --channel updates.spamassassin.org
sa-compile

#!/usr/bin/sh
#
sa-update --channel updates.spamassassin.org
sa-compile

You can configure cron to call this script once a week. Call crontab -e and add the following line.
@weekly       /path/to/your/script

@weekly /path/to/your/script


References



 

Comments

Posted by: sohbet Nov 21, 2009 @ 06:42

in fact,to say nothing more on this subject, but still would like to thank for sharing respects, hmmz. Dear Admin, I thank you for this informative article. And I thank you for this I follow your vendors. It’s verry good. I wish you continued success whould you like.

Posted by: chat Nov 23, 2009 @ 03:27

After half an hour of Google-ing and applying a little horse-sense, I discovered (from counting the lines in a Windows GUI text editor) that the blank line was at the very end, right after the last perc ("%") delimiter. Pico, as has been my experience, loves adding those blanks. (Anticipating comments on the order of "Why not use [insert favorite shell editor here]": I can say that after the third time of not being able to quit out of vim or emacs in OS X's Terminal app, pico seemed like a breath of fresh air; for all it's attendant quirks and foibles, I still prefer it to the others.)

Posted by: sohbet Nov 23, 2009 @ 03:33

thanks you cnaım

Posted by: free games online Nov 27, 2009 @ 00:22

Thanks, good post.

Posted by: online games Nov 27, 2009 @ 23:44

in fact,to say nothing more on this subject, but still would like to thank for sharing respects, hmmz. Dear Admin, I thank you for this informative article. And I thank you for this I follow your vendors. It’s verry good. I wish you continued success whould you like.

Posted by: gmt master ii Dec 07, 2009 @ 23:20

Good article! Nice Rolex gmt master ii,welcome to check our web and choose the watch you like. Thanks!

Posted by: sell ugg ugg boots online ugg boots Dec 16, 2009 @ 18:56

1 Chestnut UGG Bailey Button Boots
2 Rose UGG Classic Cardy Boots 3 Sand UGG Classic Mini Boots 4 UGG Classic Argyle Knit whit 5879 5 UGG 5822 Stripe Cable Knit Chocolate White 6 Chestunt Genuine Australia classic Tall 7 Sand UGG Ultra Shotr Boots 8 Chestnut UGG Sundance Boots



Posted by: Rc helicopters Dec 16, 2009 @ 20:11

I thinks is googd www.rcmodelhobby.com/

Posted by: ed hardy Dec 20, 2009 @ 22:38

Nothing is able to fulfill, as long as confidence. Everything is difficult at the beginning, is now at the beginning of the show that you have succeeded in half.

Posted by: flower delivery usa Dec 27, 2009 @ 03:28

Nothing is able to fulfill, as long as confidence. Everything is difficult at the beginning, is now at the beginning of the show that you have succeeded in half.

Posted by: replica rolex Dec 28, 2009 @ 00:39

We are Rolex watch experts selling only the finest, top level

condition, and preowned men's and ladies' Rolex watches, used Rolex

watches, unused Rolex watches and new Rolex watches on the market. Our

top priority is to provide every customer with the highest quality

Rolex watch at the lowest price available. Browse our wide selection

of Rolexes for sale.

Posted by: replica watches Dec 29, 2009 @ 21:53

Our watches are all beautifully decorated stainless steel or 18k gold designer replica watches,perfectly fitted to you wirst ,once you wear our watch you will never look back ,Now I will show you some thing wonderful: Rolex Replica Watches, Corum Replica Watches, Dewitt Replica Watches, Rolex Replica Watches, Ferrari Replica Watches…………

Posted by: Pes Patch Dec 30, 2009 @ 15:44

thanks great article

Posted by: Sikiş İzle Dec 30, 2009 @ 15:45

great artcle

Posted by: replica watches Jan 03, 2010 @ 21:26

We are Rolex watch experts selling only the finest, top level condition, and preowned men's and ladies' Rolex watches, used Rolex watches, unused Rolex watches and new Rolex watches on the market. Our top priority is to provide every customer with the highest quality Rolex watch at the lowest price available. Browse our wide selection of Rolexes for sale.

Posted by: replica watches Jan 03, 2010 @ 21:32

We are Rolex watch experts selling only the finest, top level condition, and preowned men's and ladies' Rolex watches, used Rolex watches, unused Rolex watches and new Rolex watches on the market. Our top priority is to provide every customer with the highest quality Rolex watch at the lowest price available. Browse our wide selection of Rolexes for sale.

Posted by: 找 工作 Jan 04, 2010 @ 23:13

highest quality Rolex watch at the lowest price available. Browse our wide selection of Rolexes for sale.

Posted by: ugg boots Jan 07, 2010 @ 04:12

Thanks, good post.

Posted by: Why is my computer slow Jan 10, 2010 @ 15:21

Thanks for the help.

Posted by: china wholesale Jan 13, 2010 @ 23:53

Hello, this is my web page, you are welcome to come, will give you rewardi [url=http://www.dvdsonsales.com/]dvd[/url] [url=http://www.dvdsonsales.com/]dvds[/url]

Posted by: film izle Jan 17, 2010 @ 04:51

Thank you for sharing your friends. Hope to see you another day.

Posted by: divx film izle Jan 17, 2010 @ 04:53

Thanks for your good website and for sharing your experiences.

Posted by: Wholesale Jan 17, 2010 @ 21:57

in fact,to say nothing more on this subject, but still would like to thank for sharing

Posted by: links of london Jan 19, 2010 @ 00:17

We are Rolex watch experts selling only the finest, top level condition, and preowned men's and ladies' Rolex watches, used Rolex watches, unused Rolex watches and new Rolex watches on the market.

Posted by: links of london Jan 19, 2010 @ 00:18

Our top priority is to provide every customer with the highest quality Rolex watch at the lowest price available. Browse our wide selection of Rolexes for sale.

Posted by: replica watches Jan 19, 2010 @ 19:17

Highest quality replica rolex will to meet your expectation.replica rolex watches are made from the highest quality parts and crafted with such attention to detail.We offer discount price for you. When you order replica rolex watches at our site

Posted by: tiffany necklaces Jan 22, 2010 @ 01:22

But the groups do not want to marry[HTML_REMOVED]Tiffany Necklaces[HTML_REMOVED]They have their own rooms and cars Nearly half of More than two percent of people have private cars



















Posted by: tiffany necklaces Jan 22, 2010 @ 01:22

But the groups do not want to marry[HTML_REMOVED]Tiffany Necklaces[HTML_REMOVED]They have their own rooms and cars Nearly half of More than two percent of people have private cars



















Posted by: tiffany necklaces Jan 22, 2010 @ 01:22

But the groups do not want to marry[HTML_REMOVED]Tiffany Necklaces[HTML_REMOVED]They have their own rooms and cars Nearly half of More than two percent of people have private cars



















Posted by: ugg boots Feb 06, 2010 @ 23:41

Wow, thanks for the insightful post. I look forward to reading more from you.

Posted by: human bowling Feb 12, 2010 @ 06:59

Thanks for the great post!

Posted by: Eloise Dog Beds Feb 12, 2010 @ 06:59

This is great information. Thanks!

Posted by: Ironman 2 News Feb 12, 2010 @ 07:00

Thanks for the help. This was very quick like you said.

Posted by: Nike Air Max Feb 22, 2010 @ 23:20

Very creative, one of the nicer sites I have seen today. Keep up the great work.

Posted by: Nike Air Max Mar 04, 2010 @ 00:32

So beautiful sharing!Thank you very much.

Posted by: tag heuer watch Mar 04, 2010 @ 23:07

can show a man not only his wealthy but also his high taste.tag heuer watch As the society developed, many people are pay more attention to one's wearing than before, especially a watch. tag heuer watch If you are wearing a famous brand watch, people will look up you, also will love to do business with you. You will be a successful man with a such luxury fashion watch.

Posted by: tag heuer watch Mar 04, 2010 @ 23:08

can show a man not only his wealthy but also his high taste.tag heuer watch As the society developed, many people are pay more attention to one's wearing than before, especially a watch. tag heuer watch If you are wearing a famous brand watch, people will look up you, also will love to do business with you. You will be a successful man with a such luxury fashion watch.

Posted by: Boost Testosterone Levels Mar 11, 2010 @ 09:19

Thanks for sharing this. That is really fast for an installation.

Leave a message

(Required)
(Required and not displayed)
(Optional)
obfuscated letters Enter the text shown in the image