{"id":174,"date":"2015-06-17T18:07:13","date_gmt":"2015-06-17T18:07:13","guid":{"rendered":"http:\/\/star.genuinewebhost.com\/~linuxguru\/tutorial\/?p=174"},"modified":"2025-07-10T03:15:37","modified_gmt":"2025-07-10T03:15:37","slug":"installing-and-configuring-spamassassin-to-work-with-postfix-smtp-server","status":"publish","type":"post","link":"http:\/\/shijuvarghese.com\/?p=174","title":{"rendered":"Installing and Configuring Spamassassin to work with Postfix SMTP server"},"content":{"rendered":"<p>Email spam, which is also know as junk email, are identical email messages sent to several email recipients. This could be emails sent by companies for marketing purposes, email sent bring user to phishing web sites, etc.<\/p>\n<p>Usually these emails are sent using some scripts to a huge number of recipients.<\/p>\n<p>Plain SMTP servers by default is not meant to analyze the emails and categorize them. They receive any email that comes it based on the basic checks. We make use of other applications such as spamassasins that filters spam mails based on content-matching rules<\/p>\n<p>Follow the steps mentioned in my previous posts to install postfix<\/p>\n<p>Install spamassassin, which is available ini common repositories<\/p>\n<ul>\n<li>]# <strong>yum install spamassassin<\/strong><\/li>\n<\/ul>\n<p>Edit the spamassasin&#8217;s configuration file as follows:<\/p>\n<ul>\n<li>]# <strong>vi \/etc\/mail\/spamassassin\/local.cf<\/strong><\/li>\n<li>required_hits 5.0<\/li>\n<li>report_safe 0<\/li>\n<li>required_score 5<\/li>\n<li>rewrite_header Subject ***SPAM***<\/li>\n<\/ul>\n<p>Add a new user to manage the spamd service<\/p>\n<ul>\n<li><strong>groupadd spamd<\/strong><\/li>\n<li><strong>useradd -g spamd -s \/bin\/false -d \/var\/log\/spamassassin spamd<\/strong><\/li>\n<li><strong>chown spamd:spamd \/var\/log\/spamassassin<\/strong><\/li>\n<\/ul>\n<p>Configure postfix configuration file<\/p>\n<ul>\n<li>]# <strong>vi \/etc\/postfix\/master.cf<\/strong><\/li>\n<\/ul>\n<p>Find the line that starts with &#8220;<strong>smtp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet<\/strong>&#8221; and edit it to looks as below:<\/p>\n<ul>\n<li># ====================================================================<\/li>\n<li># service type\u00a0 private unpriv\u00a0 chroot\u00a0 wakeup\u00a0 maxproc command + args<\/li>\n<li>#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (yes)\u00a0\u00a0 (yes)\u00a0\u00a0\u00a0\u00a0 (yes)\u00a0\u00a0\u00a0 (never)\u00a0\u00a0 (100)<\/li>\n<li># ====================================================================<\/li>\n<li>smtp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet\u00a0\u00a0 n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 smtpd -o content_filter=spamassassin<\/li>\n<\/ul>\n<p>Add the following line at the end of <strong>master.cf<\/strong><\/p>\n<ul>\n<li>spamassassin unix &#8211; n n &#8211; &#8211; pipe flags=R user=spamd argv=\/usr\/bin\/spamc -e \/usr\/sbin\/sendmail -oi -f ${sender} ${recipient}<\/li>\n<\/ul>\n<p>Verify the following file:<\/p>\n<ul>\n<li><strong>cat \/etc\/sysconfig\/spamassassin<\/strong><\/li>\n<li>Ensure that the <strong>-D<\/strong> flag is enabled in the vaariable <strong>SPAMDOPTIONS<\/strong><\/li>\n<\/ul>\n<p>Issue the following commands:<\/p>\n<ul>\n<li>]#\u00a0 sa-update<\/li>\n<li>]# service spamassassin stop<\/li>\n<li>]# service spam assassin start<\/li>\n<\/ul>\n<p>Add the following commands in a cron job to do it regularly<\/p>\n<p>Restart the mail services<\/p>\n<ul>\n<li>]# <strong>service postfix restart<\/strong><\/li>\n<li>]# <strong>service spamassassin restart<\/strong><\/li>\n<\/ul>\n<p><strong>Test<\/strong><\/p>\n<p>Send a mail to user balbox with the below subject. This will be marked as spam:<\/p>\n<p>XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Email spam, which is also know as junk email, are identical email messages sent to several email recipients. This could be emails sent by companies <a class=\"mh-excerpt-more\" href=\"http:\/\/shijuvarghese.com\/?p=174\" title=\"Installing and Configuring Spamassassin to work with Postfix SMTP server\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":1819,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,7],"tags":[],"class_list":["post-174","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-postfix"],"_links":{"self":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=174"}],"version-history":[{"count":14,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/174\/revisions"}],"predecessor-version":[{"id":351,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/174\/revisions\/351"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/media\/1819"}],"wp:attachment":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}