{"id":1040,"date":"2019-10-18T10:08:35","date_gmt":"2019-10-18T01:08:35","guid":{"rendered":"http:\/\/manatails.net\/blog\/?p=1040"},"modified":"2022-04-03T13:48:53","modified_gmt":"2022-04-03T04:48:53","slug":"setting-up-a-dedicated-spamassassin-server","status":"publish","type":"post","link":"https:\/\/manatails.net\/blog\/2019\/10\/setting-up-a-dedicated-spamassassin-server\/","title":{"rendered":"Setting up a dedicated spamassassin server"},"content":{"rendered":"<p>Default Spamassassin install from Ubuntu is a little bit misconfigured and is not suitable for remote Anti-Spam service. So I am writing up the config changes I had to make in order to make it work flawlessly.<\/p>\n<p>1. Make a dedicated user for Spamassassin, default config runs Spamassassin as root, then the executable itself would complain about it and fall back to nobody.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo adduser spamd --disabled-login<\/pre>\n<p>2. Open \/etc\/default\/spamassassin and edit the following line<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">OPTIONS=\"--create-prefs --max-children 5 --username spamd --helper-home-dir \/home\/spamd\/ --listen=0.0.0.0 --allowed-ips=(your_server_ip)\"<\/pre>\n<p>3. Edit \/etc\/spamassassin\/local.cf and Add\/Uncomment the following lines to suit your needs<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rewrite_header Subject [SPAM]\r\nuse_bayes 1\r\n\r\nbayes_path \/var\/spamassassin\/bayes_db\/bayes\r\nbayes_file_mode 0775\r\n\r\nbayes_auto_learn 1\r\n\r\nbayes_auto_learn_threshold_nonspam -0.001\r\nbayes_auto_learn_threshold_spam 10.0<\/pre>\n<p>4.Make directories for Bayes database and give appropriate permissions<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo mkdir -p \/var\/spamassassin\/bayes_db\r\nsudo chown -R spamd:spamd \/var\/spamassassin<\/pre>\n<p>5.Start Spamassassin Service<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo systemctl daemon-reload\r\nsudo systemctl restart spamassassin<\/pre>\n<p>&nbsp;<\/p>\n<p>Here are some convenient commands to manage your Spamassassin service:<\/p>\n<p>1. Restore Bayes backup data<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo -H -u spamd sa-learn --restore spamassassin.backup<\/pre>\n<p>2. Sync Bayes database<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo -H -u spamd sa-learn --sync<\/pre>\n<p>3. Learn mail in folder as spam:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo -H -u spamd sa-learn --spam --showdots --dir \/home\/manatails\/mail\/spam<\/pre>\n<p>4. Learn mail in folder as ham<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo -H -u spamd sa-learn --ham --showdots --dir \/home\/manatails\/mail\/ham<\/pre>\n<p>5. Print bayes database stats:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo -H -u spamd sa-learn --dump magic<\/pre>\n<p>In ubuntu logs are stored at \/var\/log\/mail.log<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Default Spamassassin install from Ubuntu is a little bit misconfigured and is not suitable for remote Anti-Spam service. So I am writing up the config changes I had to make in order to make it work flawlessly. 1. Make a dedicated user for Spamassassin, default config runs Spamassassin as root, then the executable itself would &hellip; <a href=\"https:\/\/manatails.net\/blog\/2019\/10\/setting-up-a-dedicated-spamassassin-server\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Setting up a dedicated spamassassin server<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[14,128],"class_list":["post-1040","post","type-post","status-publish","format-standard","hentry","category-computer","tag-linux","tag-server"],"_links":{"self":[{"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/posts\/1040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/comments?post=1040"}],"version-history":[{"count":14,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/posts\/1040\/revisions"}],"predecessor-version":[{"id":1342,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/posts\/1040\/revisions\/1342"}],"wp:attachment":[{"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/media?parent=1040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/categories?post=1040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/manatails.net\/blog\/wp-json\/wp\/v2\/tags?post=1040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}