{"id":489,"date":"2012-08-28T12:11:39","date_gmt":"2012-08-28T11:11:39","guid":{"rendered":"http:\/\/www.nooblet.org\/blog\/?p=489"},"modified":"2013-01-10T02:07:14","modified_gmt":"2013-01-10T02:07:14","slug":"dovecot-sieve-deliver-mail-based-on-spamassassin-score","status":"publish","type":"post","link":"https:\/\/www.nooblet.org\/blog\/2012\/dovecot-sieve-deliver-mail-based-on-spamassassin-score\/","title":{"rendered":"Dovecot Sieve &#8212; Deliver mail based on Spamassassin score"},"content":{"rendered":"<p>I don&#8217;t reject any spam e-mail as I want my system to learn from the contents. It gets delivered to a folder and I check it now and then.<\/p>\n<p>However the spam I receieve is beyond rediculous, approaching 400 messages a day. It isn&#8217;t feasable for me to check the spam folder for false positives.<\/p>\n<p>The following sieve rule allows me to split the spam into 2 folders based on there Spamassassin score. >=9 &#8220;Spam&#8221; .. <9 \"SpamLikely\"\n \n\n\n<pre class=\"nums:false lang:default decode:true \" >\r\nrequire [&#8220;variables&#8221;, &#8220;relational&#8221;,&#8221;comparator-i;ascii-numeric&#8221;, &#8220;regex&#8221;,&#8221;imap4flags&#8221;,&#8221;fileinto&#8221;];\r\n \r\n# Extract integer from X-Spam-Score\r\nset &#8220;iSpamLevel&#8221; &#8220;0&#8221;;\r\nif header :regex &#8220;X-Spam-Score&#8221; &#8220;([0-9]+)(\\.[0-9]+)?&#8221; {\r\n        set &#8220;iSpamLevel&#8221; &#8220;${1}&#8221;;\r\n}\r\n \r\n# rule:[SpamLikely]\r\nif allof (header :is &#8220;X-Spam-Flag&#8221; &#8220;Yes&#8221;,\r\n        string :value &#8220;lt&#8221; :comparator &#8220;i;ascii-numeric&#8221; &#8220;${iSpamLevel}&#8221; &#8220;9&#8221;)\r\n{\r\n        fileinto &#8220;SpamLikely&#8221;;\r\n}\r\n# rule:[Spam]\r\nelsif allof (header :is &#8220;X-Spam-Flag&#8221; &#8220;Yes&#8221;,\r\n        string :value &#8220;ge&#8221; :comparator &#8220;i;ascii-numeric&#8221; &#8220;${iSpamLevel}&#8221; &#8220;9&#8221;)\r\n{\r\n        fileinto &#8220;Spam&#8221;;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I don&#8217;t reject any spam e-mail as I want my system to learn from the contents. It gets delivered to a folder and I check it now and then. However the spam I receieve is beyond rediculous, approaching 400 messages a day. It isn&#8217;t feasable for me to check the spam folder for false positives. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":646,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[95],"class_list":["post-489","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-linux-dovecot-postfix-sieve-spamassassin"],"_links":{"self":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/comments?post=489"}],"version-history":[{"count":2,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/489\/revisions"}],"predecessor-version":[{"id":663,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/posts\/489\/revisions\/663"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/media\/646"}],"wp:attachment":[{"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/media?parent=489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/categories?post=489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nooblet.org\/blog\/wp-json\/wp\/v2\/tags?post=489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}