<?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>blog.lundscape.com &#187; Postfix</title>
	<atom:link href="http://blog.lundscape.com/category/postfix/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lundscape.com</link>
	<description>The Linux Journey</description>
	<lastBuildDate>Tue, 31 Jan 2012 01:55:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Configure SpamAssassin with Postfix on Ubuntu</title>
		<link>http://blog.lundscape.com/2009/05/configure-spamassassin-with-postfix-on-ubuntu/</link>
		<comments>http://blog.lundscape.com/2009/05/configure-spamassassin-with-postfix-on-ubuntu/#comments</comments>
		<pubDate>Mon, 04 May 2009 22:24:41 +0000</pubDate>
		<dc:creator>Zachary Lund</dc:creator>
				<category><![CDATA[Postfix]]></category>
		<category><![CDATA[SpamAssassin]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.lundscape.com/?p=127</guid>
		<description><![CDATA[I&#8217;ve been running a mail server for the last year and a half. When I initially set up my Postfix mail server on Ubuntu, I knew that eventually I would need to add a spam filter. I recently decided that SpamAssassin was the best choice to filter email on my mail server. I now receive [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been running a mail server for the last year and a half. When I initially set up my <a href="http://www.postfix.org/">Postfix</a> mail server on Ubuntu, I knew that eventually I would need to add a spam filter. I recently decided that <a href="http://spamassassin.apache.org/">SpamAssassin</a> was the best choice to filter email on my mail server.</p>
<p>I now receive on average more than one spam message each day. Interestingly, all of my spam is sent to an email address that I have only given out to <a href="http://www.marquette.edu/">Marquette University</a>. I guess that means they have either sold my email address or poorly secured it in their database. Neither would surprise me.</p>
<p>I used the content from two <a href="http://townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy">different</a> <a href="http://www.debuntu.org/postfix-and-pamassassin-how-to-filter-spam">tutorials</a> to get SpamAssassin up and running on my server.</p>
<p>First, I installed SpamAssassin.</p>
<pre>apt-get install spamassassin spamc</pre>
<p>Next, I created the spamd user and group. You can specify a specific uid and gid if you want.</p>
<pre>groupadd spamd
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd</pre>
<p>Then I created the spamd home directory and set the permissions.</p>
<pre>mkdir /var/log/spamassassin
chown spamd:spamd /var/log/spamassassin</pre>
<p>Then I set up some configuration for SpamAssassin. You can edit the file directly, but I use Sed so that I can automate the installation process in a script. This enables SpamAssassin, Cron, and some other options.</p>
<pre>DEFAULT_SPAMASSASSIN=/etc/default/spamassassin
mv $DEFAULT_SPAMASSASSIN $DEFAULT_SPAMASSASSIN.default
sed '
    s/ENABLED=0/ENABLED=1/
    s/CRON=0/CRON=1/
    s/^OPTIONS.*/SAHOME="\/var\/log\/spamassassin"\nOPTIONS="--create-prefs --max-children 5 --username spamd -H ${SAHOME} -s ${SAHOME}\/spamd.log"/
' $DEFAULT_SPAMASSASSIN.default > $DEFAULT_SPAMASSASSIN</pre>
<p>Then I set up the rest of the configuration for SpamAssassin. I initially set the required score to 2.0, but this caused a lot of legitimate emails (ham) to be marked as spam. The following configuration will rewrite subjects of spam messages to identify them as spam.</p>
<pre>SA_LOCAL_CF=/etc/spamassassin/local.cf
mv $SA_LOCAL_CF $SA_LOCAL_CF.default
echo "
rewrite_header Subject [***** SPAM _SCORE_ *****]
required_score           5.0
# to be able to use _SCORE_ we need report_safe set to 0
# If this option is set to 0, incoming spam is only
# modified by adding some \"X-Spam-\" headers and no
# changes will be made to the body.
report_safe     0

# Enable the Bayes system
use_bayes               1
use_bayes_rules         1
# Enable Bayes auto-learning
bayes_auto_learn        1

# Enable or disable network checks
skip_rbl_checks         0
use_razor2              0
use_dcc                 0
use_pyzor               0
" > $SA_LOCAL_CF</pre>
<p>Now that I have been running the spam filter for a couple weeks, I have had to whitelist some email addresses that send me emails with strange headers or get sent from &#8220;shady&#8221; IP addresses. This goes into the same local.cf file.</p>
<pre>whitelist_from *@hq.acm.org</pre>
<p>I find it amusing that emails from the ACM keep getting marked as spam. Next I started SpamAssassin.</p>
<pre>/etc/init.d/spamassassin start</pre>
<p>Next, I modified Postfix to send emails through the SpamAssassin filter.</p>
<pre>POSTFIX_MASTER_CF=/etc/postfix/master.cf
mv $POSTFIX_MASTER_CF $POSTFIX_MASTER_CF.default
sed 's/smtp      inet  n       -       -       -       -       smtpd/smtp      inet  n       -       -       -       -       smtpd\n\t-o content_filter=spamassassin/'  \
$POSTFIX_MASTER_CF.default > $POSTFIX_MASTER_CF
echo 'spamassassin unix -     n       n       -       -       pipe
  user=spamd argv=/usr/bin/spamc -f -e
  /usr/sbin/sendmail -oi -f ${sender} ${recipient}' >> $POSTFIX_MASTER_CF</pre>
<p>Next, reload Postfix so it will use SpamAssassin.</p>
<pre>/etc/init.d/postfix reload</pre>
<p>Once SpamAssassin is running, you can train it by passing it spam and ham emails.</p>
<pre>sa-learn -u spamd --spam --mbox /path/to/spam_mbox
sa-learn -u spamd --ham --mbox /path/to/ham_mbox</pre>
<p>After adjusting the spam threshold, training the filter with spam messages that I have acquired over the last year, and whitelisting a few problematic senders, my spam filter has been doing a good job of marking spam as spam. At this point it is easy enough to sort through the email manually and confirm that they are spam. In the future, if it ever gets bad enough, I will be able to automatically delete the messages or filter them into a different mailbox on delivery.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lundscape.com/2009/05/configure-spamassassin-with-postfix-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring a Mail Server with Postfix</title>
		<link>http://blog.lundscape.com/2009/04/configuring-a-mail-server-with-postfix/</link>
		<comments>http://blog.lundscape.com/2009/04/configuring-a-mail-server-with-postfix/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 20:22:01 +0000</pubDate>
		<dc:creator>Zachary Lund</dc:creator>
				<category><![CDATA[Postfix]]></category>
		<category><![CDATA[ACM]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Marquette University]]></category>

		<guid isPermaLink="false">http://blog.lundscape.com/?p=106</guid>
		<description><![CDATA[I gave a presentation about Postfix to the Marquette University ACM chapter. It should be a useful starting point for configuring a Postfix mail server. I include details about much of the configuration including canonical maps which was something that I initially found difficult to figure out. Rather than creating my presentation in Microsoft PowerPoint [...]]]></description>
			<content:encoded><![CDATA[<p>I gave a presentation about <a href='http://www.postfix.org/'>Postfix</a> to the Marquette University <a href="http://acm.mscs.mu.edu/">ACM</a> chapter. It should be a useful starting point for configuring a Postfix mail server. I include details about much of the configuration including canonical maps which was something that I initially found difficult to figure out.</p>
<p>Rather than creating my presentation in Microsoft PowerPoint or OpenOffice.org Impress, I decided to check out the <a href="http://latex-beamer.sourceforge.net/">LaTeX Beamer</a> package for my presentation. Since I&#8217;ve been using <a href="http://www.latex-project.org/">LaTeX</a> for a while, it wasn&#8217;t too difficult to figure out, and it worked particularly well because most of the presentation is Postfix configuration text which I could easily include in the presentation.</p>
<p>The <a href='http://blog.lundscape.com/wp-content/uploads/2009/04/postfix.pdf'>presentation</a> is available as a PDF for download.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lundscape.com/2009/04/configuring-a-mail-server-with-postfix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

