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

  • Ubuntu Debian Linux Cannot Install Wine Solution - wine1.6 : Depends: wine1.6-i386 (= 1:1.6.2-0ubuntu14.2) but it is not installable wine1.4 : Depends: wine1.6 but it is not going to be installed
  • How To Install python 3.4 3.5 and up on Linux with wine - Working Solution
  • using Xvfb on virtual remote ssh server to have X graphical programs work
  • ssh Received disconnect from port 22:2: Too many authentication failures
  • named bind errors - DNSKEY: unable to find a DNSKEY which verifies the DNSKEY RRset and also matches a trusted key for '.'
  • OpenVZ vs LXC DIR mode poor security in LXC
  • httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.d/php.conf: Cannot load modules/libphp5.so into server: /lib64/libresolv.so.2: symbol __h_errno, version GLIBC_PRIVATE not defined in file libc.s
  • Radeon R3 GPU on Debian Crashing
  • MySQL 5.7 on Debian and Ubuntu - How To Reset Root Password
  • SSH and sshfs timeout settings keepalive
  • Linux How To Add User To Additional Group
  • Howto Set Static IP on boot in initramfs for dropbear or other purposes NFS, Linux, Debian, Ubuntu, CentOS
  • Convert and install to LUKS Encrypted Drive Ubuntu 18.04 19.10 Linux Mint and Debian Based Linux
  • Debian and Netplan
  • CentOS 8 how to restart the network!
  • CentOS 8 how to convert to a bootable mdadm RAID software array
  • ADATA USB Thumb Drive Issues
  • KMODE EXCEPTION NOT HANDLED - QEMU/KVM Won't Boot Windows 2016 or 10 Image or Physical Machine
  • Linux Mint / Ubuntu / Debian Mate Disable Guest Session and Hide Usernames on Lightdm Login screen GUI
  • SSH How To Create Public/Private Key Pair and with a Larger Keysize than 2048 bits