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

  • ssh Too many authentication failures not prompting for password
  • LightDM Mint Ubuntu Debian won't start errors Nvidia Graphics
  • WARNING: Unable to determine the path to install the libglvnd EGL vendor library config files. Check that you have pkg-config and the libglvnd development libraries installed, or specify a path with --glvnd-egl-config-path. Linux Ubuntu Mint Debian E
  • How To Upgrade Linux Mint 18.2 to 18.3 to 19.x and 20.x
  • MP3s Won't Play / ID3 Version 2.4 Issues in Cars and Other MP3 Players/CDs/DVDs Solution
  • LXC Containers LXD How to Install and Configure Tutorial Ubuntu Debian Mint
  • GlusterFS HowTo Tutorial For Distributed Storage in Docker, Kubernetes, LXC, KVM, Proxmox
  • Ubuntu Mint audio output not working pulseaudio "pulseaudio[13710]: [pulseaudio] sink-input.c: Failed to create sink input: too many inputs per sink."
  • How To Shrink Dynamically Allocated VM QEMU KVM VMware Disk Image File
  • How To Enable Linux Swapfile Instead of Partition Ubuntu Mint Debian Centos
  • 404 Not Found [IP: 151.101.194.132 80] apt update Debian 11 Bullseye Solution The repository 'http://security.debian.org bullseye/updates Release' does not have a Release file.
  • WARNING: Can't download daily.cvd from db.local.clamav.net freshclam clamav error solution
  • (firefox:9562): LIBDBUSMENU-GLIB-WARNING **: Unable to get session bus: Failed to execute child process "dbus-launch" (No such file or directory) Solution
  • Debian Mint Ubuntu Which Package Provides missing top, ps and w Solution
  • Vbox Virtualbox DNS NAT Network Mode NOT working
  • Docker Tutorial HowTo Install Docker, Use and Create Docker Container Images Clustering Swarm Mode Monitoring Service Hosting Provider
  • Zoom Password Error 'That passcode was incorrect' - Solution Wrong Passcode Wrong Meeting Name
  • How To Startup and Open Remote/Local Folder/Directory in Ubuntu Linux Mint automatically upon login
  • How To Reset Windows Server Password 2019, 2022, 7, 8, 10, 11 Recovery and Removal Guide Using Linux Ubuntu Mint Debian
  • How To Create OpenVPN Server for Secure Remote Corporate Access in Linux Debian/Mint/Ubuntu with client public key authentication