<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Narnio&#187; plugin</title>
	<atom:link href="http://www.narnio.com/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.narnio.com</link>
	<description>A day in the life of a software engineer</description>
	<lastBuildDate>Sat, 04 Feb 2012 18:31:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Setting up a mailserver, continued</title>
		<link>http://www.narnio.com/2008/12/15/setting-up-a-mailserver-continued/</link>
		<comments>http://www.narnio.com/2008/12/15/setting-up-a-mailserver-continued/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 19:35:08 +0000</pubDate>
		<dc:creator>Jongerius</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[mailserver]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[spamassassin]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.narnio.com/?p=255</guid>
		<description><![CDATA[In my last article on how to setup a basic mail server in debian using postfix and dovecot, I am now continueing on how to setup some basic spam filters. The reason to split this up, well I was stupid and assumed I wouldn&#8217;t need a spam filter yet. But I forgot that I also [...]]]></description>
			<content:encoded><![CDATA[<p>In my last article on how to <a  title="First article on setting up a basic Debian mail server" href="http://www.narnio.com/2008/12/08/debian-setting-up-a-postfix-and-dovecot-mail-server/">setup a basic mail server in debian using postfix and dovecot</a>, I am now continueing on how to setup some basic spam filters. The reason to split this up, well I was stupid and assumed I wouldn&#8217;t need a spam filter yet. But I forgot that I also moved one domain to my new mail server that got 200 spam messages a day.</p>
<p>So now to repair my mistake I am adding the following features to my already existing mail server. To find out how to setup the  mail server itself read my earlier article.</p>
<ul>
<li>Use spamassassin to mark spam in the header</li>
<li>Change the mail delivery to dovecot LDA, this is needed for step 3</li>
<li>Automatically move marked e-mails to the spam folder of the user</li>
</ul>
<p>Sounds easy right. Well it should be <img src='http://www.narnio.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p><span id="more-255"></span></p>
<h2>Install spamassassin and set it up in postfix</h2>
<p>The first step we will take is installing and setting up the spamassassin tool. First lets install it with the default options from Debian by running:</p>
<p><code><br />
apt-get install spamassassin<br />
useradd -g spamd -s /bin/false -m -d /home/spamassassin spamd</code></p>
<p>Next we setup the basics of spamassassin configuration, the file called /etc/spamassassin/local.cf</p>
<p><code>report_safe        0<br />
required_score     2.0</code><br />
<code>use_bayes          1<br />
bayes_auto_learn   1<br />
use_bayes_rules    1</code></p>
<p><code># Some basic configuration<br />
score DCC_CHECK 4.000<br />
score SPF_FAIL 10.000<br />
score SPF_HELO_FAIL 10.000<br />
score RAZOR2_CHECK 2.500<br />
score BAYES_99 4.300<br />
score BAYES_95 3.500<br />
score BAYES_80 3.000</code></p>
<p><code># Headers to be added for all scanned messages<br />
add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_<br />
add_header all Level _STARS(*)_<br />
add_header all Checker-Version SpamAssassin _VERSION_ (_SUBVERSION_) on _HOSTNAME_</code></p>
<p>So what we&#8217;ve done so far is set spamassassin up to automatically learn from mail it receives and to mark anything with a bayes score over 2 as spam. But we still need to integrate it into postfix to get it to work. Add the following to the postfix configuration (/etc/postfix/master.cf):</p>
<p><code>spamassassin unix -     n       n       -       -       pipe<br />
 user=spamd argv=/usr/bin/spamc -f -e<br />
 /usr/sbin/sendmail -oi -f ${sender} ${recipient}</code></p>
<p>You will also need to change the smtp line in the same file to the following, this will set up spamassassin as a pre delivery filter:</p>
<p><code>smtp      inet  n     -     -     -     -     smtpd -o content_filter=spamassassin</code></p>
<p>This will add the spamassassin service as a unix service through a pipe connection. Sounds complicated but it&#8217;s really easy it basically uses a binary file to comunicate between postfix and spamassassin. Make sure the user <em>spamd</em> exists and create the folder <em>/usr/bin/spamc</em> with full access to the spamd user. Also edit the file spamassassin to the following:</p>
<p><code># /etc/default/spamassassin<br />
# Change to one to enable spamd<br />
ENABLED=1</code></p>
<p><code># SpamAssassin uses a preforking model, so be careful! You need to<br />
# make sure --max-children is not set to anything higher than 5,<br />
# unless you know what you're doing.<br />
SAHOME="/var/lib/spamassassin/"<br />
OPTIONS="--create-prefs --max-children 5 --username spamd --helper-home-dir ${SAHOME} -s ${SAHOME}spamd.log"<br />
PIDFILE="${SAHOME}spamd.pid"<br />
CRON=0</code></p>
<p>Make sure to create the directory <em>/var/lib/spamassassin</em> and give spamd full access right to it, otherwise the service might not run properly. Spamassassin is now setup and will start scanning your e-mail. So if all you are interested in is the header being changed to indicate if a message is spam then you are done. If you also wish yo move it to a different folder then continue reading.</p>
<h2>Settup Dovecot as LDA (Local Delivery Agent)</h2>
<p>Next step is setting up dovecot as the default LDA for postfix. This is needed to let dovecot filter messages into the proper locations. First setup the connection to the between postfix and dovecot by adding the following to the <em>/etc/postfix/master.cf</em>:</p>
<p><code>dovecot   unix  -       n       n       -       -       pipe<br />
 flags=DRhu user=dovecot:dovecot<br />
 argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}</code></p>
<p>Please note that we now need to keep track of the fact that dovecot will be the user that is running this part of the mail server. So every file needed, log or configuration and mailboxes related, need to be owned by dovecot:dovecot. I have had issues with files having the wrong owner so it is important! Before activating the postfix connection lets configure dovecot for LDA by editing the <em>/etc/dovecot/dovecot.conf</em> file. Add the following piece of code in the group auth default &gt;&gt; socket listen:</p>
<p><code>        master {<br />
          path = /var/run/dovecot/auth-master<br />
          user = dovecot<br />
          group= ssl-cert<br />
          mode = 0600<br />
        }<br />
</code></p>
<p>This will setup the authentication service that dovecot will use for delivering the e-mail to the correct user and authenticating users. Also add the following at the bottom of the file to configure the LDA of dovecot:</p>
<p><code>protocol lda {<br />
  mail_plugins = cmusieve<br />
  sieve_global_path = /etc/dovecot/globalsieverc/global.sieve<br />
  log_path = /var/log/dovecot-delivery_log<br />
  postmaster_address = <a  href="mailto:noreply@domain.com">noreply@domain.com</a><br />
}</code></p>
<p><code>plugin {<br />
 sieve = /etc/dovecot/globalsieverc/global.sieve<br />
}</code></p>
<p>Again make sure that the user dovecot has full access to both the logfile and the global sieve directory (which you will need to make) <img src='http://www.narnio.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . The plugin group is just for safety. I don&#8217;t know if it is needed but it doesn&#8217;t break anything. Also check the dovecot-mysql.conf that you made earlier to make sure that the uid and gid are those of the dovecot user. You can find this out by running:</p>
<p><code>:&gt; id dovecot</code></p>
<p>If this is all setup in dovecot restart it by running:</p>
<p><code>:&gt;/etc/init.d/dovecot force-reload</code></p>
<p>Now it is time to wrap things up and activate dovecot as the LDA for postfix, edit the file /etc/postfix/main.cf and change the virtual_transport from virtual to dovecot. Last but not least is creating the globe.sieve file.</p>
<p><code>:&gt; vi /etc/dovecot/globalsieverc/global.sieve</code></p>
<p><code>require ["fileinto"];<br />
if anyof (<br />
    header :contains ["X-Spam-Flag"] "Yes"<br />
) {<br />
    fileinto "Spam"; stop;<br />
}</code></p>
<p>Now restart postfix and send yourself a test mail. If everything is setup correctly it should be delivered to your mailbox. If not then first check &#8216;/var/log/mail.info&#8217; to gather some information as to what is going on. If this indicates a delivery was attempted but it failed then check &#8216;/var/log/dovecot-delivery_log&#8217; to find out more.</p>
<p>I hope you have fun using your spam free mail server. If you have any issues let me know, but please include snippets from the log as this will help me help you <img src='http://www.narnio.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<hr/>Copyright &copy; 2012 <strong><a  href="http://www.narnio.com">Narnio</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@jong-soft.com so we can take legal action immediately.]]></content:encoded>
			<wfw:commentRss>http://www.narnio.com/2008/12/15/setting-up-a-mailserver-continued/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working On WordPress Mobile plugin</title>
		<link>http://www.narnio.com/2008/08/02/working-on-wordpress-mobile-plugin/</link>
		<comments>http://www.narnio.com/2008/08/02/working-on-wordpress-mobile-plugin/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 13:24:21 +0000</pubDate>
		<dc:creator>Jongerius</dc:creator>
				<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.narnio.com/?p=206</guid>
		<description><![CDATA[A while back I got some questions if it was possible to create a more mobile friendly version of this blog. Appearantly I have several visitors that are browsing using mobile devices. And I must say my design is not user friendly for them. Off course they are right, any user should be able to [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I got some questions if it was possible to create a more mobile friendly version of this blog. Appearantly I have several visitors that are browsing using mobile devices. And I must say my design is not user friendly for them.</p>
<p>Off course they are right, any user should be able to access this blog. Be it from a mobile phone or a computer. So I had to find a way to offer my mobile visitors a better experience. First thing to do that is looking into the <a  title="WordPress plugin directory" href="http://wordpress.org/extend/plugins/">wordpress.org</a> plugin library. There are a lot of plugins available for a lot of different things. There had to be some for switching the display to mobile when a mobile device is detected.</p>
<p>And there are. I first tried <a  title="WordPress Mobile Edition Plugin page" href="http://wordpress.org/extend/plugins/wordpress-mobile-edition/"><strong>WordPress Mobile Edition</strong></a> which is pretty good. Big issues I had with it are that it&#8217;s not as light weight as I want it to be. And the coding is crappy! But beyond that it does what it&#8217;s supposed to.</p>
<p>But me being a developer I decided to write my own little plugin to offer a mobile version of this blog. Fully customizable using templates and settings in the admin menu. I haven&#8217;t yet completed the entire design, nor is the admin part working <img src='http://www.narnio.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . But it&#8217;s currently running on this blog <img src='http://www.narnio.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . If you want to check it out just add &#8216;?mobile=true&#8217; to any page or visit using your phone.</p>
<p>When I&#8217;m done developing the plugin I&#8217;ll share with you all how you can write a simple WordPress plugin. I will also publish the plugin for anyone to download, <strong>for free</strong>!!!</p>
<p>So stay tuned for an update&#8230;&#8230;.</p>
<hr/>Copyright &copy; 2012 <strong><a  href="http://www.narnio.com">Narnio</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact legal@jong-soft.com so we can take legal action immediately.]]></content:encoded>
			<wfw:commentRss>http://www.narnio.com/2008/08/02/working-on-wordpress-mobile-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

