{"id":1126,"date":"2017-02-20T12:41:39","date_gmt":"2017-02-20T17:41:39","guid":{"rendered":"http:\/\/easy-admin.ca\/?p=1126"},"modified":"2017-08-21T10:15:38","modified_gmt":"2017-08-21T14:15:38","slug":"configuring-spamassassin-for-postfix","status":"publish","type":"post","link":"https:\/\/easy-admin.ca\/index.php\/2017\/02\/20\/configuring-spamassassin-for-postfix\/","title":{"rendered":"Configuring SpamAssassin for Postfix"},"content":{"rendered":"<p>In the process of receiving email, spamassassin will stand between the outside world and the email services running on your server itself. If it finds, according to its definition rules and configuration, that an incoming message is spam, it will rewrite the subject line to clearly identify it as such. Let\u2019s see how.<\/p>\n<p>The main configuration file is <code>\/etc\/mail\/spamassassin\/local.cf<\/code>, and we should make sure the following options are available (add them if they are not present or uncomment if necessary):<\/p>\n<div class=\"code-label\" title=\"Configure SpamAssassin\">local.cf<\/div>\n<pre>report_safe 0\r\nrequired_score 8.0\r\nrewrite_header Subject [SPAM]\r\n<\/pre>\n<ol>\n<li>When <strong>report_safe<\/strong> is set to <strong>0<\/strong> (recommended value), incoming spam is only modified by modifying the email headers as per rewrite_header. If it is set to <strong>1<\/strong>, the message will be deleted.<\/li>\n<li>To set the aggressivity of the spam filter, <strong>required_score<\/strong> must be followed by an integer or decimal number. The lesser the number, the more sensitive the filter becomes. Setting <strong>required_score<\/strong> to a value somewhere between <strong>8.0<\/strong> and <strong>10.0<\/strong> is recommended for a large system serving many <strong>(~100s)<\/strong> email accounts.<\/li>\n<\/ol>\n<p>Once you\u2019ve saved those changes, enable and start the spam filter service, and then update the spam rules:<\/p>\n<pre># systemctl enable spamassassin\r\n# systemctl start spamassassin\r\n# sa-update<\/pre>\n<h3>Integrating Postfix and SpamAssassin<\/h3>\n<p>In order to efficiently integrate Postfix and spamassassin, we will need to create a dedicated user and group to run the spam filter daemon:<\/p>\n<pre># useradd spamd -s \/bin\/false -d \/var\/log\/spamassassin<\/pre>\n<p>Next, add the following line at the bottom of <code>\/etc\/postfix\/master.cf<\/code>:<\/p>\n<div class=\"code-label\" title=\"Add SpamAssassin with Postfix\">master.cf<\/div>\n<pre>spamassassin unix - n n - - pipe flags=R user=spamd argv=\/usr\/bin\/spamc -e \/usr\/sbin\/sendmail -oi -f ${sender} ${recipient}\r\n<\/pre>\n<p>And indicate (at the top) that spamassassin will serve as <strong>content_filter<\/strong>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1127 size-full\" src=\"https:\/\/easy-admin.ca\/wp-content\/uploads\/2017\/02\/Integrate-Postfix-with-SpamAssassin.png\" alt=\"\" width=\"770\" height=\"199\" srcset=\"https:\/\/easy-admin.ca\/wp-content\/uploads\/2017\/02\/Integrate-Postfix-with-SpamAssassin.png 770w, https:\/\/easy-admin.ca\/wp-content\/uploads\/2017\/02\/Integrate-Postfix-with-SpamAssassin-300x78.png 300w, https:\/\/easy-admin.ca\/wp-content\/uploads\/2017\/02\/Integrate-Postfix-with-SpamAssassin-768x198.png 768w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/p>\n<p>Finally, restart Postfix to apply changes:<\/p>\n<pre># systemctl restart postfix<\/pre>\n<p>To verify that <strong>SpamAssassin<\/strong> is working properly and detecting incoming spam, a test known as <strong>GTUBE<\/strong> (<strong>Generic Test for Unsolicited Bulk Email<\/strong>) is provided.<\/p>\n<p>To perform this test, send an email from a domain outside your network (such as Yahoo!, Hotmail, or Gmail) to an account residing in your email server. Set the Subject line to whatever you want and include the following text in the message body:<\/p>\n<pre>XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X<\/pre>\n<p>And shows the corresponding notice in the logs:<\/p>\n<p>Additionally, you can test <strong>spamassassin<\/strong> right from the command line:<\/p>\n<pre># spamassassin -D &lt; \/usr\/share\/doc\/spamassassin-3.4.0\/sample-spam.txt<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the process of receiving email, spamassassin will stand between the outside world and the email services running on your server itself. If it finds, according to its definition rules and configuration, that an incoming message is spam, it will rewrite the subject line to clearly identify it as such. Let\u2019s see how. The main &hellip; <a href=\"https:\/\/easy-admin.ca\/index.php\/2017\/02\/20\/configuring-spamassassin-for-postfix\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Configuring SpamAssassin for Postfix<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Configuring SpamAssassin for Postfix - HP Server","description":"In the process of receiving email, spamassassin will stand between the outside world and the email services running on your server itself. If it finds, accordin"},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1126","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts\/1126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/comments?post=1126"}],"version-history":[{"count":0,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/posts\/1126\/revisions"}],"wp:attachment":[{"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/media?parent=1126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/categories?post=1126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easy-admin.ca\/index.php\/wp-json\/wp\/v2\/tags?post=1126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}