Enable SPAMASSASSIN on Postfix in 5 minutes

Centos 5 Postfix and SPAMASSASSIN Tutorial
yum install spamassassin
chkconfig spamassassin on


vi /etc/mail/spamassassin/local.cf
##############
#required_hits 5
#report_safe 0
#rewrite_header Subject [SPAM]

#5 is the least restrictive (means only the most obvious SPAM is caught. 0 is obviously the most restrictive/sensitive and would have lots of false positives
required_score 5.0
#0 = this way the header is modified only
#1 = new message is created and original is attached
#2 = attached to new report as plain text
report_safe 0
#I don't like this option
#rewrite_header Subject **SPAM**
##############


service spamassassin restart



#Setup Postfix

vi /etc/postfix/master.cf

Edit the following lines:

Basically we're just adding this at the end of the line "-o content_filter=spamassassin"

Change:

smtp      inet  n       -       n       -       -       smtpd
To:
smtp      inet  n       -       n       -       -       smtpd -o content_filter=spamassassin


Change:
smtps     inet  n       -       n       -       -       smtpd
To:
smtps     inet  n       -       n       -       -       smtpd -o content_filter=spamassassin

Add to the end of the config:


spamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
####
service postfix restart

error

======

Feb 18 15:29:44 mailbox postfix/pipe[13415]: fatal: get_service_attr: unknown username: spamd
Feb 18 15:29:44 mailbox postfix/smtpd[13406]: disconnect from 192.168.5.91
Feb 18 15:29:45 mailbox postfix/qmgr[12261]: warning: premature end-of-input on private/spamassassin socket while reading input attribute name
Feb 18 15:29:45 mailbox postfix/qmgr[12261]: warning: private/spamassassin socket: malformed response
Feb 18 15:29:45 mailbox postfix/qmgr[12261]: warning: transport spamassassin failure -- see a previous warning/fatal/panic logfile record for the problem description
Feb 18 15:29:45 mailbox postfix/master[12258]: warning: process /usr/libexec/postfix/pipe pid 13415 exit status 1
Feb 18 15:29:45 mailbox postfix/master[12258]: warning: /usr/libexec/postfix/pipe: bad command startup -- throttling
Feb 18 15:29:45 mailbox postfix/qmgr[12261]: B5F4C337002D: to=<user@localbox.com>, relay=none, delay=1.3, delays=0.22/1/0/0, dsn=4.3.0, status=deferred (unknown mail transport error)

##
#####fixed (use correct user and group in spamassasssin line):
##
Feb 18 19:39:40 mailbox dovecot: auth(default): new auth connection: pid=30122
Feb 18 19:40:03 mailbox postfix/smtpd[29887]: connect from 192.168.5.91
Feb 18 19:40:03 mailbox dovecot: auth(default): client in: AUTH    2    PLAIN    service=smtp    resp=AGpzQHJlYWx0ZWNodGFsay5jb20AV1JYU1RpMjAwNQ==
Feb 18 19:40:03 mailbox dovecot: auth(default): passwd-file(user@localbox.com): lookup: user=user@localbox.com file=/etc/dovecot.passwd
Feb 18 19:40:03 mailbox dovecot: auth(default): client out: OK    2    user=user@localbox.com
Feb 18 19:40:04 mailbox postfix/smtpd[29887]: 043DD337002E: client=192.168.5.91, sasl_method=PLAIN, sasl_username=user@localbox.com
Feb 18 19:40:04 mailbox postfix/cleanup[29895]: 043DD337002E: message-id=<4D5F3B93.9070803@re.com>
Feb 18 19:40:04 mailbox postfix/qmgr[29844]: 043DD337002E: from=<user@localbox.com>, size=306, nrcpt=1 (queue active)
Feb 18 19:40:04 mailbox spamd[8024]: spamd: connection from localhost.localdomain [127.0.0.1] at port 59429
Feb 18 19:40:04 mailbox spamd[8024]: spamd: setuid to mailuser succeeded
Feb 18 19:40:04 mailbox spamd[8024]: spamd: processing message <4D5F3B93.9070803@re.com> for mailuser:102
Feb 18 19:40:04 mailbox spamd[8024]: spamd: identified spam (5.8/5.0) for mailuser:102 in 0.0 seconds, 331 bytes.
Feb 18 19:40:04 mailbox spamd[8024]: spamd: result: Y 5 - DNS_FROM_OPENWHOIS,FH_DATE_PAST_20XX,NO_RECEIVED,NO_RELAYS scantime=0.0,size=331,user=mailuser,uid=102,required_score=5.0,rhost=localhost.localdomain,raddr=127.0.0.1,rport=59429,mid=<4D5F3B93.9070803@re.com>,autolearn=no
Feb 18 19:40:04 mailbox postfix/pickup[29843]: 604203370033: uid=102 from=<user@localbox.com>
Feb 18 19:40:04 mailbox postfix/cleanup[29895]: 604203370033: message-id=<4D5F3B93.9070803@re.com>
Feb 18 19:40:04 mailbox postfix/pipe[29899]: 043DD337002E: to=<user@localbox.com>, relay=spamassassin, delay=0.45, delays=0.4/0/0/0.05, dsn=2.0.0, status=sent (delivered via spamassassin service)
Feb 18 19:40:04 mailbox postfix/qmgr[29844]: 043DD337002E: removed
Feb 18 19:40:04 mailbox postfix/qmgr[29844]: 604203370033: from=<user@localbox.com>, size=850, nrcpt=1 (queue active)


=======
enable Razor DCC
yum install razor-agents

You don't need to run any commands or change config files, it should work right away after a spamassassin restart.  The command below and that other guides mention are only if you want to report SPAM I believe.

Now just restart spamassassin and you should see razor in action in the headers (only when it detects something though):

 

	*  1.5 RAZOR2_CF_RANGE_E8_51_100 Razor2 gives engine 8 confidence level
	*      above 50%
	*      [cf: 100]
	*  0.5 RAZOR2_CHECK Listed in Razor2 (http://razor.sf.net/)
	*  0.5 RAZOR2_CF_RANGE_51_100 Razor2 gives confidence level above 50%
	*      [cf: 100]

 

Don't follow below, it just screws things up:

====
vi /etc/mail/spamassassin/.razor

razor-admin -home=/etc/mail/spamassassin/.razor -register
razor-admin -home=/etc/mail/spamassassin/.razor -create
razor-admin -home=/etc/mail/spamassassin/.razor -discover

echo "razor_config /etc/mail/spamassassin/.razor/razor-agent.conf" >> /etc/mail/spamassassin/local.cf

Latest Articles

  • Linux Screen How To Scroll Up and Down
  • Directadmin Install Segfault Error
  • Could not display "trash:///". Error: DBus error org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout
  • SSH error slow login debug1: An invalid name was supplied Cannot determine realm for numeric host address - Solution
  • How To Install CPanel
  • LOG: MAIN PANIC failed to expand condition "${if eq {$authenticated_id}{}{0}{${if eq {$sender_address}{$local_part@$domain}{0}{${if match{$received_protocol}{N^e?smtps?a$N}{${perl{checkbx_autowhitelist}{$authenticated_id}}}{${if eq{$received_prot
  • Firefox 11 closes/quits without saving Open Tabs Prompt Solution/Fix
  • Firefox 11 stop hiding http:// and https:// solution fix
  • The Importance of a High Quality Power Supply/Power Supplies To Prevent Overheating/System Crash/Hardware Damage
  • Asus VE247H 23.7" Inch LCD/LED Backlit Monitor Dead/Stuck Pixel Policy Complaint
  • Firefox Error ./firefox-bin: error while loading shared libraries: libxul.so: cannot open shared object file: No such file or directory
  • Linux Ubuntu Nvidia GT430 Lockups/Errors/Freezes NVRM: os_schedule: Attempted to yield the CPU while in atomic or interrupt context
  • Xen how to mount disk images off-line and access data
  • Xen non-HVM container won't work/boot anymore
  • how to exit xen console session from xm
  • Skype Linux/Ubuntu Sound Echo/Distortion Poor Quality Problem Fix Solution
  • Ubuntu 10.04 Flash Videos have tearing/lines Solution
  • File /etc/vz/conf/ve-vps.basic.conf-sample not found: No such file or directory - Openvz Error solution
  • Ubuntu 10 Nvidia Drivers Not Updated After Kernel Update Solution/How-To Manually Rebuild nvidia kernel modules for Ubuntu
  • What's Needed To Fix Linux