Using Google Apps with Your VPS
Mar 09, 2007I mentioned previously that I had opted to go with Google Apps for your domain rather than go through the trouble of setting up a mail server and spam filter on my new VPS at Slicehost.
My biggest motivation for doing this was not wanting to deal with the learning curve that comes with setting up Postfix and Spam Assassin. The other reason was that I’m quite happy with trying to stay with a simple 256mb account right now, and setting up yet more software on top of what I already need (Apache, Rails, Subversion, and Trac) would make that more difficult.
After a few weeks with this setup I’m reasonably happy with it. Here how to go about getting your email hosting switched over to Google Apps.
Basic Setup
I’m going to assume you’re already setup with your brand spankin’ new VPS, and that DNS is provided (I know both Slicehost and Rimuhosting do this). I’m also assuming you already have the domain you want to use pointing to your account. At the very minimum you should be able to display a basic index.html page when people visit http://yourdomain.com/.
First thing to do is sign up for a Google Apps account. The process is very straight forward, shouldn’t take more than 5 minutes. When Google asks to verify your domain I’d suggest just going with the HTML check, as it’s much easier than dealing with changing DNS records.
After a brief pause you should have access to the Google Apps suite, including Gmail. The next step is to set up an MX record for Gmail.
Creating an MX Record
These instructions are for Slicehost, but most DNS setups should be similar.
- Log in to manage.slicehost.com
- Go to the DNS records for your account
- Switch to the advanced view
- Click on ‘records’ for your domain
- Add a new record
- Type: MX
- Name: yourdomain.tld.
- Data: ASPMX.L.GOOGLE.COM.
- Aux Info: 1
- Save record
The end result is that all traffic to your website is still directed to your VPS (your primary A record), but all email will be redirected to Google’s mail servers.
POP3 and Your Mail Client
Google doesn’t offer IMAP access for Gmail, instead only providing POP3. This makes some sense since Gmail basically keeps all your email in one large stack and uses search views instead of folders. I was a bit concerned about the lack of IMAP at first, since I’ve been used to it for a long time now. I believe my wife actually quoted me as saying once: “POP3 is so 1995.”
(Note: You need to explicitly login to Gmail and activate POP3 access in the settings.)
Anyway, the nice thing is that the way Google has set up POP3 for Gmail it actually turns out to not be too much of a hassle.
Keeping Received Mail in Sync
The first thing to do is to tell your mail client (I use Mail.app on my Mac) to not delete any messages from the server when downloading new messages. Also change your Gmail settings to have Gmail archive a copy when you get mail through POP3 (it’s moved from your Inbox to All Mail).
This way you won’t see messages in your inbox on Gmail you’ve already read, but you won’t lose any mail either regardless of whether you’re using Gmail or a mail client.
Keeping Sent Mail in Sync
If you send a message from Gmail’s web interface it will send a copy to you when you access your account with your mail client. All you have to do is set up a filter rule to move any message you receive with your email in the “From:” line to your Sent Mail folder. This ends up keeping your sent mail in sync on both ends. It’s a bit of a hack, but it mimics IMAP fairly well.
Last Steps
You should be set up now, and all that is left to do is test it out. Google has pretty good help docs for getting everything set up, and the only thing that could cause any hiccups is the time it takes for your MX Record changes to take effect.
Now you can enjoy still having your email address, but instead getting to use Gmail’s great interface and pretty rock solid spam filtering.