Welcome to Kotyk.com

Aliasing a Sub-domain with Postfix and Gmail

Posted March 13th, 2013

Google Apps doesn’t allow wildcards for a subdomain which we need to be able to handle replies coming into The Mentor Center.

This tutorial is developed for Ubuntu 12.10 but may work for earlier versions.

First, setup DNS to handle the subdomain MX record. We use DNS Made Easy because their features, price and performance are pretty much perfect. Adjust the following to work with your DNS provider.

```sub.domain.com. MX 10 aliasingservername.
sub.domain.com. MX 20 mx1.dnsmadeeasy.com.```
The second entry is a backup spool. You’ll need to be paying for that.

Then setup postfix. We set it up to only allow relaying for specified domains so we don’t get blacklisted.

You’ll want the following lines in /etc/postfix/main.cf

```virtual_alias_domains = sub.domain.com```
```virtual_alias_maps = hash:/etc/postfix/virtual```

Edit the virtual file with the subdomain and catch-all address.

```vi /etc/postfix/virtual```
```@sub.domain.com [email protected]```

When you are done, run

```postmap /etc/postfix/virtual```

Restart postfix.
```service postfix restart```

About Sheldon Kotyk

Father of three girls. Husband of one wife. Dog person. My wife has cats.
Read More

Follow If You Wanna