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=, 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=, 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=
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=, 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=, 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


Tags:

enable, spamassassin, postfix, minutescentos, tutorial, yum, install, chkconfig, vi, etc, cf, required_hits, report_safe, rewrite_header, spam, restrictive, positives, required_score, header, modified, text, restart, edit, adding, quot, content_filter, smtp, inet, smtpd, smtps, config, unix, flags, user, spamd, argv, usr, bin, spamc, sbin, sendmail, oi, sender, recipient, feb, mailbox, fatal, get_service_attr, username, disconnect, qmgr, premature, input, socket, attribute, malformed, previous, logfile, libexec, pid, startup, throttling, localbox, relay, delays, dsn, deferred, spamassasssin, dovecot, auth, default, resp, agpzqhjlywx, zwnodgfsay, jb, av, jyu, rpmjawnq, passwd, lookup, ok, dd, sasl_method, sasl_username, cleanup, nrcpt, queue, active, localhost, localdomain, setuid, mailuser, succeeded, processing, identified, bytes, dns_from_openwhois, fh_date_past_, xx, no_received, no_relays, scantime, uid, rhost, raddr, rport, autolearn, pickup, via, razor, dcc, commands, guides, headers, detects, _cf_range_e, _, _check, listed, http, sf, _cf_range_, screws, admin, register, echo, razor_config, conf,

Latest Articles

  • Centos 7 how to save iptables rules like Centos 6
  • nfs tuning maximum amount of connections
  • qemu-kvm error "Could not initialize SDL(No available video device) - exiting"
  • Centos 7 tftpd will not work with selinux enabled
  • Debian Ubuntu Mint Howto Create Bridge (br0)
  • How To Control Interface that dhcpd server listens to on Debian based Linux like Mint and Ubuntu
  • LUKS unable to type password to unlock during boot on Debian, Ubuntu and Mint
  • Debian Ubuntu and Linux Mint Broken Kernel After Date - New Extra Module Naming Convention
  • Wordpress overwrites and wipes out custom htaccess rules and changes soluton
  • Apache htaccess and mod_rewrite how to redirect and force all URLs and visitors to the SSL / HTTPS version
  • python 3 pip cannot install mysql module
  • QEMU-KVM won't boot Windows 2016 or 2019 server on an Intel Core i3
  • Virtualbox vbox not starting
  • Bind / named not responding to queries solution
  • Linux Mint How To Set Desktop Background Image From Bash Prompt CLI
  • ImageMagick Convert PDF Not Authorized
  • ImageMagick Converted PDF to JPEG some files have a black background solution
  • Linux Mint Mate Customize the Lock screen messages and hide username and real name
  • Ubuntu/Gnome/Mint/Centos How To Take a partial screenshot
  • ssh how to verify your host key / avoid MIM attacks