{"id":115,"date":"2006-11-22T23:04:37","date_gmt":"2006-11-22T21:04:37","guid":{"rendered":"http:\/\/jerome.harckmans.be\/?p=115"},"modified":"2006-11-22T23:04:37","modified_gmt":"2006-11-22T21:04:37","slug":"maildrop-postfix","status":"publish","type":"post","link":"https:\/\/jerome.harckmans.be\/?p=115","title":{"rendered":"Maildrop + Postfix"},"content":{"rendered":"<p>Our server runs <a href=\"http:\/\/www.postfix.org\/\">Postfix<\/a> as MTA: it&#8217;s a very powerful mail server, highly configurable, and extremely efficient when used in combination with amavis, spamassassin, mysql, cyrus-sasl and courier-imap.<\/p>\n<p>Spamassassin is really THE indispensable tool in today&#8217;s internet environment, where about <a href=\"http:\/\/en.wikipedia.org\/wiki\/E-mail_spam#As_a_percentage_of_the_total_volume_of_e-mail\">80% of e-mails<\/a> are spams!<\/p>\n<p>Before using spamassassin, I simply couldn&#8217;t dissociate abusive e-mails from real ones (of course, words like viagra or pe*is elongation in the subject were clear hints \ud83d\ude09 ). Then, once spamassassin has been put in place (through the use of <a href=\"http:\/\/www.ijs.si\/software\/amavisd\/\">amavis<\/a>), detected spams were marked with &#8220;***SPAM***&#8221; in the subject. It was then simply a matter of setting a rule in Thunderbird in order to get rid of those fu***in spam e-mails.<\/p>\n<p>But still, a problem remains when using a webmail: spam e-mails were simply displayed in the Inbox folder, which really irritated me in the end. So I looked for a solution to automatically sort e-mail at reception time&#8230; That&#8217;s where maildrop appears!<\/p>\n<p><a href=\"http:\/\/www.courier-mta.org\/maildrop\/\">Maildrop<\/a> is normally delivered with the <a href=\"http:\/\/www.courier-mta.org\/\">courier<\/a> MTA, but as we are using Postfix, we had to emerge it:<\/p>\n<div class=coding># emerge maildrop -va<\/div>\n<p>Some postfix adaptation is needed so that it uses maildrop to deliver the mail instead of the postfix\/virtual process (when using virtual users of course). Add or adapt the following in <strong>\/etc\/postfix\/main.cf<\/strong><\/p>\n<div class=coding>\n<pre>\nvirtual_transport = maildrop\nmaildrop_destination_recipient_limit = 1\nmailbox_command = \/usr\/bin\/maildrop\n<\/pre>\n<\/div>\n<p>Then make sure to have a line like the following in <strong>\/etc\/postfix\/master.cf<\/strong> (of course, the user vmail has to exist on your system):<\/p>\n<div class=coding>\n<pre>\nmaildrop  unix  -       n       n       -       -       pipe\n  flags=DRhu user=vmail argv=\/usr\/bin\/maildrop -w 90 -d ${user}@${nexthop} &#92;\n${user} ${nexthop} ${sender}\n<\/pre>\n<\/div>\n<p>All mail users being stored in a database, simply replace the &#8220;virtual:&#8221; in the destination field of the transport table by &#8220;maildrop:&#8221; for the domains you want to serve using maildrop. The others will simply continue to perform as before.<\/p>\n<p>The last thing to do is to create either a <strong>\/etc\/maildroprc<\/strong> or a <strong>~\/.mailfilter<\/strong> file (or both of course). The former defines rules to be applied to all accounts, while the latter does the same but only for the accounts that belongs to a specific user. Here is what such a file may look like to automatically move detected spam to a Spam folder (and create it if necessary):<\/p>\n<div class=coding>\n<pre>\n`test -d $DEFAULT`\nif( $RETURNCODE == 1 )\n{\n`\/usr\/bin\/mkdir -p $DEFAULT`\n`\/usr\/bin\/rmdir $DEFAULT`\n`\/usr\/bin\/maildirmake $DEFAULT`\n}\nif ((\/^X-Spam-Status: YES\/))\n{\n`test -d $DEFAULT\/.Spam`\nif( $RETURNCODE == 1 )\n{\n`\/usr\/bin\/maildirmake $DEFAULT\/.Spam`\n`echo \"INBOX.Spam\" >> $DEFAULT\/courierimapsubscribed`\n}\nto \"$DEFAULT\/.Spam\/\"\n}\n<\/pre>\n<\/div>\n<p>Make sure the permission on that file is 600, and that the file is owned by that specific user.<\/p>\n<p>Those steps have made the internet a better and safer place to live with \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our server runs Postfix as MTA: it&#8217;s a very powerful mail server, highly configurable, and extremely efficient when used in combination with amavis, spamassassin, mysql, cyrus-sasl and courier-imap. Spamassassin is<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,6],"tags":[],"_links":{"self":[{"href":"https:\/\/jerome.harckmans.be\/index.php?rest_route=\/wp\/v2\/posts\/115"}],"collection":[{"href":"https:\/\/jerome.harckmans.be\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jerome.harckmans.be\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jerome.harckmans.be\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jerome.harckmans.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":0,"href":"https:\/\/jerome.harckmans.be\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"wp:attachment":[{"href":"https:\/\/jerome.harckmans.be\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jerome.harckmans.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jerome.harckmans.be\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}