pig-monkey.com - google appshttps://pig-monkey.com/2012-12-22T00:00:00-08:00An Ubuntu VPS on Slicehost: Mail2008-06-10T00:00:00-07:002012-12-22T00:00:00-08:00Pig Monkeytag:pig-monkey.com,2008-06-10:/2008/06/an-ubuntu-vps-on-slicehost-mail/<p><em>As <a href="http://pig-monkey.com/2008/06/09/a-move-to-slicehost/">mentioned previously</a>, I’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’s email to Google …</a></p><p><em>As <a href="http://pig-monkey.com/2008/06/09/a-move-to-slicehost/">mentioned previously</a>, I’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’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>
<!--more-->
<p>Installing Postfix is a simple matter. Telnet is used quite a bit for testing, so I install that too:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>$ sudo aptitude install postfix telnet mailutils
</code></pre></div></td></tr></table></div>
<p>The Postfix setup will ask how it should be installed – we want the “Internet Site” option – and then ask you for your fully qualified domain name.</p>
<p>Done? Let’s make sure Postfix is running:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>$ telnet localhost <span class="m">25</span>
</code></pre></div></td></tr></table></div>
<p>If it’s working Postfix should return:</p>
<div class="highlight"><pre><span></span><code>Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 localhost ESMTP Postfix (Ubuntu)
</code></pre></div>
<p>Let’s send a test message from root to the user account <code>user</code> (replace that with whatever your standard user is):</p>
<div class="highlight"><pre><span></span><code><span class="n">ehlo</span><span class="w"> </span><span class="n">localhost</span><span class="w"></span>
<span class="n">mail</span><span class="w"> </span><span class="k">from</span><span class="err">:</span><span class="w"> </span><span class="n">root</span><span class="nv">@localhost</span><span class="w"></span>
<span class="n">rcpt</span><span class="w"> </span><span class="k">to</span><span class="err">:</span><span class="w"> </span><span class="k">user</span><span class="nv">@localhost</span><span class="w"></span>
<span class="k">data</span><span class="w"></span>
<span class="nl">Subject</span><span class="p">:</span><span class="w"> </span><span class="n">Test</span><span class="w"></span>
<span class="n">Hi</span><span class="p">,</span><span class="w"> </span><span class="k">is</span><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="n">thing</span><span class="w"> </span><span class="k">on</span><span class="vm">?</span><span class="w"></span>
<span class="p">.</span><span class="w"></span>
<span class="n">quit</span><span class="w"></span>
</code></pre></div>
<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’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’s being handled by Google Apps), so mine looks like:</p>
<div class="highlight"><pre><span></span><code>mydestination = server.mydomain.com, localhost.mydomain.com , localhost
</code></pre></div>
<p>Restart Postfix if you made any changes:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>$ sudo /etc/init.d/postfix restart
</code></pre></div></td></tr></table></div>
<p>Right. Now let’s send another test. Notice this time we’re using full domain names, instead of localhost:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span></pre></div></td><td class="code"><div><pre><span></span><code>$ telnet server.mydomain.com <span class="m">25</span>
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
</code></pre></div></td></tr></table></div>
<p>Working? Good.</p>
<p>Let’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:</p>
<div class="highlight"><pre><span></span><code># Allow mail server connections
-A INPUT -p tcp -m state --state NEW --dport 25 -j ACCEPT
</code></pre></div>
<p>Now let’s apply the rules:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>$ sudo iptables-restore < /etc/iptables.test.rules
</code></pre></div></td></tr></table></div>
<p>Make sure everything looks dandy:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>$ sudo iptables -L
</code></pre></div></td></tr></table></div>
<p>If it meets your fancy, save the rules:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code>$ sudo -i
$ iptables-save > /etc/iptables.up.rules
</code></pre></div></td></tr></table></div>
<p>And now, from your local computer, let’s test it out.</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span></pre></div></td><td class="code"><div><pre><span></span><code>$ telnet server.mydomain.com <span class="m">25</span>
ehlo server.mydomain.com
mail from: root@server.mydomain.com
rcpt to: user@server.mydomain.com
data
Subject: remote connection <span class="nb">test</span>
Hello, you.
.
quit
</code></pre></div></td></tr></table></div>
<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:</p>
<div class="highlight"><pre><span></span><code>virtual_alias_domains = myvirtualdomain.com
virtual_alias_maps = hash:/etc/postfix/virtual
</code></pre></div>
<p>Create the <code>/etc/postfix/virtual</code> file referenced above and add the aliases:</p>
<div class="highlight"><pre><span></span><code><span class="k">alias</span><span class="nv">@myvirtualdomain</span><span class="p">.</span><span class="n">com</span><span class="w"> </span><span class="k">user</span><span class="nv">@mydomain</span><span class="p">.</span><span class="n">com</span><span class="w"></span>
</code></pre></div>
<p>Turn it into a database:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code>$ <span class="nb">cd</span> /etc/postfix
$ sudo postmap virtual
</code></pre></div></td></tr></table></div>
<p>Restart Postfix:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>$ sudo /etc/init.d/postfix restart
</code></pre></div></td></tr></table></div>
<p>Attempt to send an email to the new alias at the virtual domain:</p>
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span>
<span class="normal">9</span></pre></div></td><td class="code"><div><pre><span></span><code>$ telnet server.mydomain.com <span class="m">25</span>
ehlo server.mydomain.com
mail from: root@server.mydomain.com
rcpt to: alias@myvirtualdomain.com
data
Subject: virtual domain <span class="nb">test</span>
I hope this works!
.
quit
</code></pre></div></td></tr></table></div>
<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:</p>
<div class="highlight"><pre><span></span><code><span class="k">user</span><span class="nv">@mydomain</span><span class="p">.</span><span class="n">com</span><span class="w"></span>
</code></pre></div>
<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:</p>
<div class="highlight"><pre><span></span><code>user
</code></pre></div>
<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>Google Apps2008-06-09T00:00:00-07:002012-09-15T00:00:00-07:00Pig Monkeytag:pig-monkey.com,2008-06-09:/2008/06/google-apps/<p>Last week I outsourced my email to <a href="http://google.com/a/">Google Apps</a>.</p>
<p>For years, my paranoia has prevented me from moving my mail. I never liked the idea of Google parsing through each message for keywords to generate ads. In fact, I usually don’t even allow Google to cookie me. But now …</p><p>Last week I outsourced my email to <a href="http://google.com/a/">Google Apps</a>.</p>
<p>For years, my paranoia has prevented me from moving my mail. I never liked the idea of Google parsing through each message for keywords to generate ads. In fact, I usually don’t even allow Google to cookie me. But now most of my regular email contacts have started using GPG. Enough of my mail is now encrypted that I’m comfortable with Google.</p>
<p>I haven’t decided yet if I prefer the Gmail interface or Thunderbird. In the web interface, I use <a href="http://getfiregpg.org/">FireGPG</a> for signing and d/encrypting, which of courses places signatures inline. Since I’m jumping back and forth between that and Thunderbird/Enigmail, in order to maintain some measure of consistency, I’ve told Enigmail to sign inline instead of using PGP/Mime. It is a bit annoying, and will probably frighten the sheeple, but that’s the way it is for now.</p>
<p>So, please encrypt all email. And if you don’t, be aware that Google is reading it.</p>