<?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>pig-monkey.com &#187; postfix</title>
	<atom:link href="http://pig-monkey.com/tag/postfix/feed/" rel="self" type="application/rss+xml" />
	<link>http://pig-monkey.com</link>
	<description>Here are recorded many goings and comings, doings and beings; stories, symbols and meanings. Gossamer threads that may be woven into a larger web: a story of this Age of the World.</description>
	<lastBuildDate>Sun, 25 Jul 2010 08:11:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>An Ubuntu VPS on Slicehost: Mail</title>
		<link>http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-mail/</link>
		<comments>http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-mail/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 19:04:36 +0000</pubDate>
		<dc:creator>Pig Monkey</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[google apps]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[slicehost]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://www.pig-monkey.com/?p=1413</guid>
		<description><![CDATA[As mentioned previously, I&#8217;ve recently moved this domain over to Slicehost. What follows is Part Three of a guide, compiled from my notes, to setting up an Ubuntu Hardy VPS. See also Part One, Part Two, and Part Four. Last week I moved this domain&#8217;s email to Google Apps. Slicehost has a guide to creating <a href="http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-mail/">[...]</a>]]></description>
			<content:encoded><![CDATA[<p><em>As <a href="http://pig-monkey.com/2008/06/09/a-move-to-slicehost/">mentioned previously</a>, I&#8217;ve recently moved this domain over to <a href="http://www.slicehost.com/">Slicehost</a>. What follows is Part Three of a guide, compiled from my notes, to setting up an Ubuntu Hardy VPS. See also <a href="http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-basic-setup">Part One</a>, <a href="http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-web-server">Part Two</a>, and <a href="http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-wordpress">Part Four</a>.</em></p>
<p>Last week I <a href="http://pig-monkey.com/2008/06/09/google-apps/">moved this domain&#8217;s email to Google Apps</a>. Slicehost has <a href="http://articles.slicehost.com/2007/10/25/creating-mx-records-for-google-apps">a guide to creating MX records for Google Apps</a>. I have a couple other domains with Google Apps, along with a couple domains hosted locally with addresses that simply forward to my primary, Google hosted, email. I also need to send mail from the server. To accomplish all of this, I use <a href="http://www.postfix.org/">Postfix</a>.</p>
<p><span id="more-1413"></span></p>
<p>Installing Postfix is a simple matter. Telnet is used quite a bit for testing, so I install that too:<br />
<pre>
$ sudo aptitude install postfix telnet
</pre></p>
<p>The Postfix setup will ask how it should be installed &#8212; we want the &#8220;Internet Site&#8221; option &#8212; and then ask you for your fully qualified domain name.</p>
<p>Done? Let&#8217;s make sure Postfix is running:<br />
<pre>
$ telnet localhost 25
</pre></p>
<p>If it&#8217;s working Postfix should return:<br />
<pre>
Trying 127.0.0.1...
Connected to localhost.
Escape character is &#039;^]&#039;.
220 localhost ESMTP Postfix (Ubuntu)
</pre></p>
<p>Let&#8217;s send a test message from root to the user account <code>user</code> (replace that with whatever your standard user is):<br />
<pre>
ehlo localhost
mail from: root@localhost
rcpt to: user@localhost
data
Subject: Test

Hi, is this thing on?

.
quit 
</pre></p>
<p>Now, check your email as <code>user</code> by running <code>mail</code>. See the message? Good.</p>
<p>Open <code>/etc/postfix/main.cf</code> to make sure that Postfix knows what domains it&#8217;s receiving mail for. To do this, edit the <code>mydestination</code> variable to include all the proper domains. For me, the name of my server looks like server.mydomain.com. I want Postfix to accept mail for that domain, but not for mydomain.com (since that&#8217;s being handled by Google Apps), so mine looks like:<br />
<pre>
mydestination = server.mydomain.com, localhost.mydomain.com , localhost
</pre></p>
<p>Restart Postfix if you made any changes:<br />
<pre>
$ sudo /etc/init.d/postfix restart
</pre></p>
<p>Right. Now let&#8217;s send another test. Notice this time we&#8217;re using full domain names, instead of localhost:<br />
<pre>
$ telnet server.mydomain.com 25
ehlo server.mydomain.com
mail from: root@server.mydomain.com
rcpt to: user@server.mydomain.com
data
Subject: domains!
woot... I think this works.
.
quit
</pre></p>
<p>Working? Good.</p>
<p>Let&#8217;s test from the outside. The first step is to open up the correct ports in the firewall. Assuming you have iptables configured in the way the <a href="http://articles.slicehost.com/2007/11/6/ubuntu-gutsy-setup-page-1">Slicehost article suggests</a>, open up your <code>/etc/iptables.test.rules</code> and add the following:<br />
<pre>
# Allow mail server connections
## SMTP
-A INPUT -p tcp -m state --state NEW --dport 25 -j ACCEPT 
</pre></p>
<p>Now let&#8217;s apply the rules:<br />
<pre>
$ sudo iptables-restore &lt; /etc/iptables.test.rules
</pre></p>
<p>Make sure everything looks dandy:
</pre>
<p><pre>
$ sudo iptables -L
</pre></p>
<p>If it meets your fancy, save the rules:<br />
<pre>
$ sudo -i
$ iptables-save &gt; /etc/iptables.up.rules
</pre></p>
<p>And now, from your local computer, let's test it out.<br />
<pre>
$ telnet server.mydomain.com 25
ehlo server.mydomain.com
mail from: root@server.mydomain.com
rcpt to: user@server.mydomain.com
data
Subject: remote connection test
Hello, you.
.
quit
</pre></p>
<p>Now check your mail on the mail server as before. Once again, everything should be working.</p>
<p>Now we need to setup a virtual domain. Remember, I don't want any virtual users. I only want aliases at a virtual domain to forward to my primary email address. That makes this relatively simple. (Be very, very happy. You should have seen this guide before, when I was still hosting virtual domains with virtual users!) Open up <code>/etc/postfix/main.cf</code> and add the following:<br />
<pre>
virtual_alias_domains = myvirtualdomain.com
virtual_alias_maps = hash:/etc/postfix/virtual
</pre></p>
<p>Create the <code>/etc/postfix/virtual</code> file referenced above and add the aliases:<br />
<pre>
alias@myvirtualdomain.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; user@mydomain.com
</pre></p>
<p>Turn it into a database:<br />
<pre>
$ cd /etc/postfix
$ sudo postmap virtual
</pre></p>
<p>Restart Postfix:<br />
<pre>
$ sudo /etc/init.d/postfix restart
</pre></p>
<p>Attempt to send an email to the new alias at the virtual domain:<br />
<pre>
$ telnet server.mydomain.com 25
ehlo server.mydomain.com
mail from: root@server.mydomain.com
rcpt to: alias@myvirtualdomain.com
data
Subject: virtual domain test
I hope this works!
.
quit
</pre></p>
<p>The message should now be in your primary email inbox!</p>
<p>As long as we're setting up forwards, let's forward system account mail to somewhere where it'll actually get read. To do so, create a <code>~/.forward</code> file with the following contents:<br />
<pre>
user@mydomain.com
</pre></p>
<p>Let's also create a <code>/root/.forward</code>, so that roots mail gets forwarded to my local account (where it is then forwarded to my primary email). Root's forward would simply read:<br />
<pre>
user
</pre></p>
<p>Next up: <a href="http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-wordpress">install WordPress with rewrites</a>. (Previously, we did a <a href="http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-basic-setup">basic setup</a> and <a href="http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-web-server">installed a web server</a>.)</p>
]]></content:encoded>
			<wfw:commentRss>http://pig-monkey.com/2008/06/10/an-ubuntu-vps-on-slicehost-mail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
