{"id":964,"date":"2018-04-09T10:51:10","date_gmt":"2018-04-09T10:51:10","guid":{"rendered":"https:\/\/chemicloud.com\/kb\/?post_type=article&#038;p=964"},"modified":"2020-08-09T19:32:26","modified_gmt":"2020-08-09T19:32:26","slug":"how-to-train-spamassassin","status":"publish","type":"ht_kb","link":"https:\/\/chemicloud.com\/kb\/article\/how-to-train-spamassassin\/","title":{"rendered":"How to train SpamAssassin"},"content":{"rendered":"<p>By default, Spamassassin is set to auto learn on all inbound mail. This works fairly well in most cases by itself and you normally don\u2019t have to do anything. In most cases, it will get more accurate over time.<\/p>\n<p>However, in some situations, it may be helpful to train SpamAssassin yourself. This will help prevent good emails from going to spam, and bad emails from getting to your inbox.<\/p>\n<p>To set this up, you need to use the sa-learn program\u00a0which is only available to customers who have their email addresses configured to utilize the IMAP service.<\/p>\n<h3 id=\"how-to-train-spamassassin\">How to train SpamAssassin<\/h3>\n<p>1) Create a folder titled spam within webmail or your email client.<\/p>\n<p>2) Subscribe to the newly created spam folder using the Subscribe\/Unsubscribe Folder feature of your webmail or email client.<\/p>\n<p>3) Next, we need to set up a cron jobs to automate the training process. For information on how to configure the commands listed below in a cronjob, please choose your panel from the link below.<\/p>\n<ul>\n<li>\n<p class=\"mkb-page-title\"><strong><a href=\"https:\/\/chemicloud.com\/kb\/article\/setup-manage-cron-jobs\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to setup and manage Cron Jobs<\/a><\/strong><\/p>\n<\/li>\n<\/ul>\n<p>We will need to configure both of the commands\u00a0individually within their own cron jobs to ensure that the learning process\u00a0will work.<\/p>\n<p><strong>Example #1:<\/strong><\/p>\n<p><em>To have training learn from\u00a0<strong>one email address on a specific domain<\/strong>\u00a0that you have configured:<\/em><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/usr\/local\/cpanel\/3rdparty\/bin\/sa-learn -p ~\/.spamassassin\/user_prefs --spam ~\/mail\/$domain.tld\/$mailbox\/.spam\/{cur,new} &gt;\/dev\/null 2&gt;&amp;1<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/usr\/local\/cpanel\/3rdparty\/bin\/sa-learn -p ~\/.spamassassin\/user_prefs --ham ~\/mail\/$domain.tld\/$mailbox\/{cur,new} &gt;\/dev\/null 2&gt;&amp;1<code><\/code><\/pre>\n<p><strong>Example #2:<\/strong><\/p>\n<p><em>To have training learn from\u00a0<strong>all the\u00a0email address of a particular\u00a0domain<\/strong>\u00a0that you have configured:<\/em><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/usr\/local\/cpanel\/3rdparty\/bin\/sa-learn -p ~\/.spamassassin\/user_prefs --spam ~\/mail\/$domain.tld\/*\/.spam\/{cur,new} &gt;\/dev\/null 2&gt;&amp;1<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/usr\/local\/cpanel\/3rdparty\/bin\/sa-learn -p ~\/.spamassassin\/user_prefs --ham ~\/mail\/$domain.tld\/*\/{cur,new} &gt;\/dev\/null 2&gt;&amp;1\r\n<code><\/code><\/pre>\n<p><strong>Example #3:<\/strong><\/p>\n<p><em>To have training learn from\u00a0<strong>all the\u00a0email address on\u00a0all additional\u00a0domains<\/strong>\u00a0that you have configured:<\/em><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/usr\/local\/cpanel\/3rdparty\/bin\/sa-learn -p ~\/.spamassassin\/user_prefs --spam ~\/mail\/*\/*\/.spam\/{cur,new} &gt;\/dev\/null 2&gt;&amp;1<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/usr\/local\/cpanel\/3rdparty\/bin\/sa-learn -p ~\/.spamassassin\/user_prefs --ham ~\/mail\/*\/*\/{cur,new} &gt;\/dev\/null 2&gt;&amp;1<\/pre>\n    \t\t<div class=\"hts-messages hts-messages--info    \"   >\r\n    \t\t\t    \t\t\t    \t\t\t\t<p>\r\n    \t\t\t\t\t<strong>Please Note:<\/strong>\u00a0This will send all\u00a0messages that SpamAssassin believes to be good (ham) into your inbox and all the messages that it finds bad (spam) into the spam folder on your account. If a spam message slips through the filter and ends up in your inbox, simply move it to your spam folder instead of deleting it as this will allow the program to learn that this message should be in spam the next time it runs. This is also the case for when a message that is good(ham) ends up in the spam folder, simply move it back to your inbox.    \t\t\t\t<\/p>\r\n    \t\t\t    \t\t\t\r\n    \t\t<\/div><!-- \/.ht-shortcodes-messages -->\r\n    \t\t\n<p>In the event that\u00a0you\u00a0wish to change the folder\u00a0in which your spam and ham messages are filtered to, you will need to repeat the same steps as above where you create the folder, subscribe to it and then schedule the cron job. The only change is that you need to modify the folder name in the path for your cron job.<\/p>\n    \t\t<div class=\"hts-messages hts-messages--info    \"   >\r\n    \t\t\t    \t\t\t    \t\t\t\t<p>\r\n    \t\t\t\t\t<strong>Please note:<\/strong>\u00a0The commands are case sensitive, so if you create a folder as Good then you must specify it as .Good in your command (see below)    \t\t\t\t<\/p>\r\n    \t\t\t    \t\t\t\r\n    \t\t<\/div><!-- \/.ht-shortcodes-messages -->\r\n    \t\t\n<p><strong>Example 4:<\/strong><\/p>\n<p><em>To have training learn from<strong>\u00a0one\u00a0email address on one domain using custom folders<\/strong>\u00a0(junk &amp; good).<\/em><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/usr\/local\/cpanel\/3rdparty\/bin\/sa-learn -p ~\/.spamassassin\/user_prefs --spam ~\/mail\/$domain.tld\/$mailbox\/.junk\/{cur,new} &gt;\/dev\/null 2&gt;&amp;1<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/usr\/local\/cpanel\/3rdparty\/bin\/sa-learn -p ~\/.spamassassin\/user_prefs --ham ~\/mail\/$domain.tld\/$mailbox\/.good\/{cur,new} &gt;\/dev\/null 2&gt;&amp;1<\/pre>\n<p>That\u2019s it! You now know how to set up training with SpamAssassin. If you have any questions, please feel free to leave a comment below, or you can contact our 24\/7 support team via <a href=\"https:\/\/lab.chemicloud.com\" target=\"_blank\" rel=\"noopener noreferrer\">Client Area<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, Spamassassin is set to auto learn on all inbound mail. This works fairly well in most cases by itself and you normally don\u2019t have to do anything. In most cases, it will get more accurate over time. However, in some situations, it may be helpful to train SpamAssassin&#8230;<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"ht-kb-category":[177],"ht-kb-tag":[],"class_list":["post-964","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-spam-protection"],"_links":{"self":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/964","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/comments?post=964"}],"version-history":[{"count":4,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/964\/revisions"}],"predecessor-version":[{"id":3353,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/964\/revisions\/3353"}],"wp:attachment":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/media?parent=964"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=964"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}