Linode Ubuntu Mail Server: Part 2 - Setting up catch all forwarding or Google Apps for your domain with Gmail

|
Catch all forwarding
My original plans for this mail server was to have everything forwarded to my Gmail account so that I would not need to check a separate 24 Hour Apps account. To set this up was quite simple. The first step is to edit /etc/postfix/main.cf as root and set myhostname = localhost This will prevent postfix conflicts with your virtual alias domains. To specify virtual alias domains add the following lines to main.cf:

virtual_alias_domains = example1.com example2.com
virtual_alias_maps = hash:/etc/postfix/virtual

The setting virtual_alias_domains is a space separated list of all domains that postfix should accept mail for. If you have email addresses for subdomains you should add them to. The virtual_alias_maps setting specifies the file that postfix uses to look up where alias addresses should go.

To create the map file create the file virtual in /etc/postfix and add lines similar to the following:

@example.com example@gmail.com

To do specific email address forwarding (for Alice) and local user forwarding (for Bob) see the following:

alice@example.com alice@gmail.com
bob@example.com bob

The final step after creating your virtual file is to create a hash map of it to speed up postfix. You can do it by using the command sudo postmap virtual from the /etc/postfix directory. Now just call sudo /etc/init.d/postfix restart to restart postfix and test your changes.

Google Apps for your domain and Gmail
If you are using Gmail as your forwarding destination you may find nearly all of your forwarded emails going into the spam folder; I did. Looking into the spam folder found that Gmail's querying of message sources were returning with the error:

Received-SPF: softfail (google.com: domain of transitioning example@example.com does not designate [your server ip] as permitted sender)

The cause of this is most likely the lack of SPF configuration on my mail server. However instead of trying to deal with SPF settings, I opted to have Gmail as my main mail server for incoming emails.

To set up Gmail as your main email server you will need to set up a standard edition account. Then you will need to verify your domain and update your Linode MX DNS records. The Linode settings to use are:

Mail Server   Preference
ASPMX.L.GOOGLE.COM  10
ALT1.ASPMX.L.GOOGLE.COM  20
ALT2.ASPMX.L.GOOGLE.COM  20
ASPMX2.GOOGLEMAIL.COM  30
ASPMX3.GOOGLEMAIL.COM  30
ASPMX4.GOOGLEMAIL.COM  30
ASPMX5.GOOGLEMAIL.COM  30

Note that the mail server addresses do not have an ending ".". While Google's documentation may specify it for other DNS servers Linode's does not require and will fail to add the MX record if you include it.

Once your MX server settings have been verified by Google you can set up a catch all account in Google App's dashboard or create individual email addresses with their own forwarding rules.

1 comments:

Goli said...

This is such a wonderful and amazing tutorial. I was easily able to configure my domain mail with all the options. Thanks a lot.

Post a Comment