<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.townx.org" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>townx - Simple Spamassassin setup with Postfix and Dovecot on Ubuntu Breezy - Comments</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy</link>
 <description>Comments for &quot;Simple Spamassassin setup with Postfix and Dovecot on Ubuntu Breezy&quot;</description>
 <language>en</language>
<item>
 <title>dui lawyer cost
What an</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-46592</link>
 <description>&lt;p&gt;&lt;a href=&quot;http://www.duilawyercost.us/&quot;&gt;dui lawyer cost&lt;/a&gt;&lt;br /&gt;
What an amazing place - it really looks stunning. I like the authentic cowboy hats too!&lt;/p&gt;</description>
 <pubDate>Wed, 22 May 2013 14:09:38 -0500</pubDate>
 <dc:creator>praid_nespunch</dc:creator>
 <guid isPermaLink="false">comment 46592 at http://www.townx.org</guid>
</item>
<item>
 <title>viagra
Thanks for sharing, I</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-46543</link>
 <description>&lt;p&gt;&lt;a href=&quot;http://japanviagraplus.org/&quot;&gt;viagra&lt;/a&gt;&lt;br /&gt;
Thanks for sharing, I Think that is what I have been looking for.&lt;/p&gt;</description>
 <pubDate>Mon, 20 May 2013 11:46:46 -0500</pubDate>
 <dc:creator>tedius_lemyur</dc:creator>
 <guid isPermaLink="false">comment 46543 at http://www.townx.org</guid>
</item>
<item>
 <title>pear</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-46320</link>
 <description>&lt;p&gt;&lt;a href=&quot;http://goldnoemploymentverificationpaydayloans.us/&quot;&gt;cash advance online&lt;/a&gt;&lt;br /&gt;
Well this is very interesting indeed.Would love to read a little more of this. admire the valuable information you offer in your articles.&lt;/p&gt;</description>
 <pubDate>Sun, 12 May 2013 12:37:55 -0500</pubDate>
 <dc:creator>ginger_toppy</dc:creator>
 <guid isPermaLink="false">comment 46320 at http://www.townx.org</guid>
</item>
<item>
 <title>What a surprise! I must say</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-46243</link>
 <description>&lt;p&gt;What a surprise! I must say that I am reading this information for the first time in my life and I am loving it badly. I will bookmark this post for sure and get back here later.&lt;br /&gt;
Regards, Frank from &lt;a href=&quot;http://www.buydetoxpassdrugtest.us/&quot;&gt;pass a drug test&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 08 May 2013 13:23:43 -0500</pubDate>
 <dc:creator>frankie55</dc:creator>
 <guid isPermaLink="false">comment 46243 at http://www.townx.org</guid>
</item>
<item>
 <title>Great Post. I have not been</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-46047</link>
 <description>&lt;p&gt;Great Post. I have not been visiting the site recently. Took a visit again and there were some great comments on the site. Excellent post. Keep up the good work.&lt;br /&gt;
&lt;a href=&quot;http://belgravia-villa.com.sg&quot;&gt;Belgravia Villas&lt;/a&gt;&lt;/p&gt;</description>
 <pubDate>Fri, 26 Apr 2013 00:51:32 -0500</pubDate>
 <dc:creator>Guest</dc:creator>
 <guid isPermaLink="false">comment 46047 at http://www.townx.org</guid>
</item>
<item>
 <title>Really helpful even in december 2012</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-43933</link>
 <description>&lt;p&gt;This was really helpful even in december 2012.&lt;/p&gt;

&lt;p&gt;I just launched Snup.nu, and tries to avoid spam from the emails listed on the frontpage. This I hope helps.&lt;/p&gt;</description>
 <pubDate>Thu, 13 Dec 2012 01:59:01 -0600</pubDate>
 <dc:creator>Tom Frank Christensen</dc:creator>
 <guid isPermaLink="false">comment 43933 at http://www.townx.org</guid>
</item>
<item>
 <title>What is the -f option for</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-42150</link>
 <description>&lt;p&gt;spamassassin unix -     n       n       -       -       pipe&lt;br /&gt;
        user=spamd argv=/usr/bin/spamc -f -e  &lt;br /&gt;
        /usr/sbin/sendmail -oi -f ${sender} ${recipient}&lt;/p&gt;

&lt;p&gt;This is a very elegant way of doing it - I have seen several examples that use a script to call spamc and in turn sendmail.&lt;br /&gt;
What is the -f for in the spamc call?  It isn&#039;t in the man for spamc.  Is this a typo?&lt;br /&gt;
Also the man page for spamc says for the -e option &quot;Note that there is a very slight chance mail will be lost here, because if the fork-and-exec fails there&#039;s no place to put the mail message.&quot;  I still like this option.&lt;/p&gt;</description>
 <pubDate>Sat, 23 Jun 2012 16:16:04 -0500</pubDate>
 <dc:creator>Justin</dc:creator>
 <guid isPermaLink="false">comment 42150 at http://www.townx.org</guid>
</item>
<item>
 <title>corpora</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-41800</link>
 <description>&lt;p&gt;correct form is &#039;corpora&#039; (decl. &lt;span class=&quot;caps&quot;&gt;IV.&lt;/span&gt;)&lt;/p&gt;</description>
 <pubDate>Fri, 10 Feb 2012 08:57:15 -0600</pubDate>
 <dc:creator>bandie</dc:creator>
 <guid isPermaLink="false">comment 41800 at http://www.townx.org</guid>
</item>
<item>
 <title>&gt; apt-get install</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-41619</link>
 <description>&lt;p&gt;&amp;gt; apt-get install spamassassin spamc&lt;br /&gt;
Seems like a misprint.&lt;/p&gt;</description>
 <pubDate>Fri, 04 Nov 2011 16:20:00 -0500</pubDate>
 <dc:creator>Guest</dc:creator>
 <guid isPermaLink="false">comment 41619 at http://www.townx.org</guid>
</item>
<item>
 <title>Crikey, I haven&#039;t got a clue</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-41589</link>
 <description>&lt;p&gt;Crikey, I haven&#039;t got a clue I&#039;m afraid. It&#039;s been a long time since I did this. Apologies for not being able to help.&lt;/p&gt;</description>
 <pubDate>Wed, 19 Oct 2011 09:54:00 -0500</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">comment 41589 at http://www.townx.org</guid>
</item>
<item>
 <title>Help! i cannot start spamassassin</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-41572</link>
 <description>&lt;p&gt;I tried to follow but i got this error instead. I cannot start the spam assassin&lt;/p&gt;

&lt;p&gt;Error as follow:&lt;/p&gt;

&lt;p&gt;warn: archive-iterator: no access to start: 2 at /usr/share/perl5/Mail/SpamAssassin/ArchiveIterator.pm line 771.&lt;/p&gt;

&lt;p&gt;Please help..&lt;/p&gt;</description>
 <pubDate>Thu, 06 Oct 2011 03:59:05 -0500</pubDate>
 <dc:creator>Serene</dc:creator>
 <guid isPermaLink="false">comment 41572 at http://www.townx.org</guid>
</item>
<item>
 <title>Thanks!</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-41459</link>
 <description>&lt;p&gt;Very helpful indeed.&lt;/p&gt;</description>
 <pubDate>Sun, 07 Aug 2011 18:27:24 -0500</pubDate>
 <dc:creator>richard</dc:creator>
 <guid isPermaLink="false">comment 41459 at http://www.townx.org</guid>
</item>
<item>
 <title>Very useful</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-41440</link>
 <description>&lt;p&gt;Thank you for this detailed guide, it works perfect in my Ubuntu Server 11.04.&lt;br /&gt;
Best regards!&lt;/p&gt;</description>
 <pubDate>Fri, 22 Jul 2011 16:31:48 -0500</pubDate>
 <dc:creator>Fer</dc:creator>
 <guid isPermaLink="false">comment 41440 at http://www.townx.org</guid>
</item>
<item>
 <title>Apologies, I intended my</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-41437</link>
 <description>&lt;p&gt;Apologies, I intended my response in a light-hearted fashion. Should have done a smiley probably. :)&lt;/p&gt;</description>
 <pubDate>Tue, 19 Jul 2011 04:07:45 -0500</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">comment 41437 at http://www.townx.org</guid>
</item>
<item>
 <title>Huh?</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comment-41392</link>
 <description>&lt;p&gt;After writing &quot;There are probably spam corpuses (corpi?) you can use for this&quot;, you didn&#039;t expect anyone to comment with the correct form? Personally I couldn&#039;t care less which form people use, but it seemed like you actually wanted to know. Sorry if I offended you, that wasn&#039;t the intention.&lt;/p&gt;</description>
 <pubDate>Mon, 20 Jun 2011 17:32:56 -0500</pubDate>
 <dc:creator>Madsen</dc:creator>
 <guid isPermaLink="false">comment 41392 at http://www.townx.org</guid>
</item>
<item>
 <title>Simple Spamassassin setup with Postfix and Dovecot on Ubuntu Breezy</title>
 <link>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy</link>
 <description>&lt;p&gt;Below is a simple Spamassassin setup for use with Postfix; I also cover how to train Spamassassin on a Maildir mail box (I use Dovecot).&lt;/p&gt;

&lt;p&gt;Some of the below is cribbed from &lt;a href=&quot;http://www.debuntu.org/postfix-and-pamassassin-how-to-filter-spam&quot; title=&quot;http://www.debuntu.org/postfix-and-pamassassin-how-to-filter-spam&quot;&gt;http://www.debuntu.org/postfix-and-pamassassin-how-to-filter-spam&lt;/a&gt;. I&#039;ve simplified it and left more of the configuration at the defaults. You don&#039;t have to do this on a locally-hosted Postfix server: the instructions are the same for any email server which can receive email (it just so happens mine isn&#039;t open to the outside world and is just passed email by fetchmail). I&#039;m working on Ubuntu Breezy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; Use these instructions at your own risk. I am not an expert on spam filtering: this set of instructions just gave me what I needed to do my own local spam filtering. If you set it up and it loses you the email clinching a one million dollar contract, I assume no responsibility.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;By the way, you need to do all of the below as root.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;Install Spamassassin&lt;/h2&gt;



&lt;pre&gt;
apt-get install spamassassin spamc
&lt;/pre&gt;



&lt;h2&gt;Configure Spamassassin user and group&lt;/h2&gt;

&lt;p&gt;We want it to run as non-root, so add a &lt;strong&gt;spamd&lt;/strong&gt; user and group:&lt;/p&gt;



&lt;pre&gt;
# groupadd spamd
# useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
# mkdir /var/log/spamassassin
# chown spamd:spamd /var/log/spamassassin
&lt;/pre&gt;



&lt;p&gt;(This sets the spamd user&#039;s home directory as /var/log/spamassassin.)&lt;/p&gt;

&lt;h2&gt;Configure Spamassassin&lt;/h2&gt;

&lt;p&gt;Edit /etc/default/spamassassin so these options are set:&lt;/p&gt;



&lt;pre&gt;
ENABLED=1

SAHOME=&amp;quot;/var/log/spamassassin/&amp;quot;

OPTIONS=&amp;quot;--create-prefs --max-children 2 --username spamd \
-H ${SAHOME} -s ${SAHOME}spamd.log&amp;quot;
&lt;/pre&gt;



&lt;p&gt;--max-children spawns the specified number of child processes (you might need more on a busy server), --username specifies the username spamd runs under, -H sets the home directory, -s sets the log file.&lt;/p&gt;

&lt;p&gt;(I left the rest of the file alone, and didn&#039;t touch /etc/spamassassin/local.cf.)&lt;/p&gt;

&lt;h2&gt;Start the Spamassassin daemon (spamd)&lt;/h2&gt;



&lt;pre&gt;
/etc/init.d/spamassassin start
&lt;/pre&gt;



&lt;p&gt;(By default, spamassassin gets added to the startup scripts by Ubuntu, so it will start/stop with your system.)&lt;/p&gt;

&lt;h2&gt;Configure Postfix to use Spamassassin as a filter&lt;/h2&gt;

&lt;p&gt;This makes Postfix pipe email to Spamassassin once it&#039;s been received. Edit /etc/postfix/master.cf and add this line as the first line of the file:&lt;/p&gt;



&lt;pre&gt;
smtp      inet  n       -       -       -       -       smtpd
        -o content_filter=spamassassin
&lt;/pre&gt;



&lt;p&gt;Add this to the end of the same file:&lt;/p&gt;



&lt;pre&gt;
spamassassin unix -     n       n       -       -       pipe
        user=spamd argv=/usr/bin/spamc -f -e  
        /usr/sbin/sendmail -oi -f ${sender} ${recipient}
&lt;/pre&gt;



&lt;p&gt;I bet you&#039;re asking yourself &quot;What the hell?!&quot;. I know I was. As far as I can tell, this sets up an &lt;a href=&quot;http://www.postfix.org/FILTER_README.html&quot;&gt;after-queue content filter&lt;/a&gt;, and this config. does the following:&lt;/p&gt;


&lt;ol&gt;
&lt;li&gt;Sets up a content filter called &lt;em&gt;spamassassin&lt;/em&gt; with type &lt;em&gt;unix&lt;/em&gt; (i.e. listening on a Unix socket).&lt;/li&gt;
&lt;li&gt;&quot;- n n - -&quot; means the filter is private, privileged (any pipe daemon needs privileges), not chrooted (pipe daemons can&#039;t be chrooted), has no wakeup set, and uses the default for maximum processes spawned, respectively.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;pipe&lt;/em&gt; sets the filter up using the pipe daemon: stuff gets passed into it by Postfix, then it either returns what was passed in, possibly changed (e.g. with headers added or the body sanitised), or a code indicating what the filter did.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;userd&lt;/em&gt; specifies the user to run the filter as.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;argv&lt;/em&gt; sets the command for the pipe daemon to run over messages (i.e. this is the actual filter command). In this case, the command is:&lt;br /&gt;
&lt;code&gt;/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}&lt;/code&gt;&lt;br /&gt;
This runs spamc (the Spamassassin client program), piping its output into the sendmail command; spamc passes the email being filtered to the Spamassassin daemon (spamd) which is running in the background; spamc gets the email back with a few spam headers to show the email has been checked, and possibly with its content rewritten to show the standard Spamassassin &quot;Spam detection software, running on the system &#039;briar&#039;, has identified this incoming email as possible spam&quot; if the email is spam. The ${sender} and ${recipient} markers are interpolated by Postfix, so that sendmail can take the output from spamc and deliver the message with the correct from and to addresses.&lt;/li&gt;
&lt;/ol&gt;



&lt;p&gt;Reload Postfix for the configuration to take:&lt;/p&gt;



&lt;pre&gt;
/etc/init.d/postfix reload
&lt;/pre&gt;



&lt;h2&gt;Train the Spamassassin filter&lt;/h2&gt;

&lt;p&gt;This was the bit where I had to do the most research. I&#039;m using Maildir format for my email, under dovecot; email for localhost accounts goes in /home/user/Maildir.&lt;/p&gt;

&lt;p&gt;To do my training, I created a new Junk folder for my localhost Postfix account: I did this by adding the folder via Thunderbird. Next I got a load of existing spam from my Trash folder, and moved it to the Junk folder.&lt;/p&gt;

&lt;p&gt;Then, to train the filter on the Junk folder, I used sa-learn like this (you need to be root, which is why the sudo is there):&lt;/p&gt;



&lt;pre&gt;
sudo sa-learn --spam -u spamd --dir /home/ell/Maildir/.Junk/* -D
&lt;/pre&gt;



&lt;p&gt;You can also train it what the good stuff looks like, e.g. run it over a clean inbox (no spam):&lt;/p&gt;



&lt;pre&gt;
sudo sa-learn --ham -u spamd --dir /home/ell/Maildir/.INBOX/* -D
&lt;/pre&gt;



&lt;p&gt;There are probably spam corpuses (corpi?) you can use for this or some other smart method I missed, but this seems to work.&lt;/p&gt;

&lt;h2&gt;Testing&lt;/h2&gt;

&lt;p&gt;Get the content out of an existing spam, send it to an account on your protected server from a free email account (you could even set up a Hotmail account to get the most accurate spam scenario), and see if Spamassassin marks it. Check the logs (/var/log/spamassassin and /var/log/mail.log) to see what happened to the email. If Postfix is using Spamassassin properly, you should see something like this in the logs:&lt;/p&gt;



&lt;pre&gt;
Jan 26 14:56:10 localhost postfix/pipe[12139]: 9CBD5DA4BF: \
to=&amp;lt;ell@localhost&amp;gt;, relay=spamassassin, delay=17, status=sent (localhost)
&lt;/pre&gt;



&lt;p&gt;(Notice the mention of postfix/pipe.)&lt;/p&gt;

&lt;p&gt;Spamassassin might not mark the email, as it will be coming from a legitimate email address. The important thing is that the logs report that Spamassassin was applied.&lt;/p&gt;

&lt;h2&gt;Results&lt;/h2&gt;

&lt;p&gt;I now get very little spam delivered to my inbox: most of it gets marked as spam by the Postfix server using Spamassassin, and Thunderbird deletes any emails with a SpamAssassin spam header for me. I periodically train the filter to make it improve, using the stuff Thunderbird has decided is junk.&lt;/p&gt;

&lt;h2&gt;Why?&lt;/h2&gt;

&lt;p&gt;Originally, this was at the top of this post, but it&#039;s kind of irrelevant. I&#039;ve included it here so you know why I put myself through this lunacy.&lt;/p&gt;

&lt;p&gt;I have a couple of legacy email accounts which still get the occasional proper email, plus endless spam. I use the excellent fetchmail to download email from these moribund accounts and send it to my local Postfix server instead. I then read my local email account via the Dovecot imap server (setup to use Maildir layouts) in the Thunderbird email client. A fairly complex setup, but one which has worked well for me over the past three or four years.&lt;/p&gt;

&lt;p&gt;However, a vast amount of spam used to hit my old email accounts, and I&#039;d have to wait for Thunderbird to sort it out (which it does well) once fetchmail passed it to the local Postfix server. I got tired of having to teach the Thunderbird junk controls, so decided instead to setup my local Postfix server with Spamassassin: the stuff that fetchmail then pulls down and sends to my local Postfix server goes through Spamassassin before it hits Thunderbird. As you can tell Thunderbird to trust Spamassassin &lt;span class=&quot;caps&quot;&gt;SPAM &lt;/span&gt;headers, it will automatically delete anything which Spamassassin has already decided is spam. Which means I don&#039;t have to teach Thunderbird, and can just teach Spamassassin instead (which is an automatic process), and let it learn by itself too as it finds more spam.&lt;/p&gt;</description>
 <comments>http://www.townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy#comments</comments>
 <category domain="http://www.townx.org/tech">tech</category>
 <category domain="http://www.townx.org/howtos">howtos</category>
 <pubDate>Fri, 26 Jan 2007 09:00:05 -0600</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">530 at http://www.townx.org</guid>
</item>
</channel>
</rss>
