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


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

  • How high can a Xeon CPU get?
  • bash fix PATH environment variable "command not found" solution
  • Ubuntu Linux Mint Debian Redhat Youtube Cannot Play HD or 4K videos, dropped frames or high CPU usage with Nvidia or AMD Driver
  • hostapd example configuration for high speed AC on 5GHz using WPA2
  • hostapd how to enable and use WPS to connect wireless devices like printers
  • Dell Server Workstation iDRAC Dead after Firmware Update Solution R720, R320, R730
  • Cloned VM/Server/Computer in Linux won't boot and goes to initramfs busybox Solution
  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease
  • nvidia cannot resume from sleep Comm: nvidia-sleep.sh Tainted: Linux Ubuntu Mint Debian
  • zfs and LUKS how to recover in Linux
  • [error] (28)No space left on device: Cannot create SSLMutex Apache Solution Linux CentOS Ubuntu Debian Mint