Virtual domains

Today’s lessons:

So a couple of weeks ago when I was down in Cornwall visiting the folks, I got collared into setting up a web site for them. Nothing fancy, just a quick and simple hack to get some content online for them. I registered a domain through 123-reg, dropped the pages onto a server, and set 123-reg mail forwarding to personal email accounts elsewhere. I’ll link to it once a DNS transfer has completed.

Within a couple of days I was receiving frustrated emails from the family to say that mails were bouncing, and when I did a quick test it turned out to be true. This tallied with experiences I vaguely recalled (too late) from Paul, who ended up moving mail onto our server rather than have it trashed by 123-reg.

Postfix to the rescue! This stuff is probably old hat to most people, but it was new to me, so I’m documenting it here.

As well as all the usual mailserver stuff it does, including handling virtual mail accounts for a bunch of people on our server, it seems you can also arbitrarily do virtual domain hosting and forward mail elsewhere. Here’s the magic ingredients to get anything sent to foo.com resent to specific email addresses elsewhere:

/etc/postfix/main.cf:

virtual_alias_domains = foo.com

virtual_alias_maps = hash:/etc/postfix/virtual


/etc/postfix/virtual:

@foo.com someone@bar.com, someoneelse@wibble.com

A quick “postmap /etc/postfix/virtual” and “postfix reload“, and we’re in business. Except, of course, hotmail sucks, and took forever to receive my emails. When it did, it chucked my emails into the junk box, disagreeing with SpamAssassin on my server and Google’s spam filtering.

Google Mail, of course, was lightning fast (going “Ding!” almost as soon as I’d hit send), and correctly identifying the messages as not spam. Just what I needed for testing the new setup.

This will come in handy for redirecting various mail accounts to Google as well, when I finally get bored of running my own mail servers!

This entry was posted in Planet. Bookmark the permalink.

One Response to Virtual domains

  1. Dave says:

    All my various email addresses are forwarded to Gmail now – especially now that it picks up which account an email was sent to and automatically replies from there.

    Gmail’s just too good not to use for everything!