Need help understanding postfix aliases vs. virtual domains. I want emails to forward to my Gmail account.

Posted February 21, 2015 12.5k views

I do not want to deal with any mail on my server. All I want is for my something like me@allmydomains.tld to forward to

mydestination vs virtual_alias_domains
I have read probably 10 tutorials and some say to list all my domains under mydestination and others say to list them all under virtual_alias_domains. So which is it?

aliases vs virtual
Again, many tutorials talk about setting up forwarding in the /etc/postfix/aliases file and others talk about doing it in /etc/postfix/virtual so I’m again lost as to which I should be using?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Typically you would only use virtualmailboxdomains etc, if you are hosting more than one domain on the same server. If you are hosting more than one domain use virtual domains, if not then use mydestination. If you are hosting multiple domains the I normally set mydestination to be the FQDN of the server i.e. mailserver.example.tld (as opposed to example.tld for a single domain server). It’s probably a good idea to add localhost to your mydestination.

Virtual alias domains do a 1 to 1 mapping of the local part (the bit before the @ symbol in an email address) of the virtual domain to it’s target domain but ONLY IF the local part is listed in one of the virtualaliasmaps (you can have none or more maps; separated by commas). These maps (or map) can have various backends; file, hash file, ldap, sql etc.

So in your can you’d probably want to do something like this (a name like <name> can be replaced with anything (don’t actually add the angle brackets!));


look inside the file called <filename> for the alias mappings

virtualaliasmaps = hash:/etc/postfix/<filename>

virtual-alias.domain anything

The first entry in the virtualaliasmaps file must have the keyword “virtual-alias.domain” in the first entry. The second entry can be anything as it is disregarded.

After that put all the fully qualified aliases and their destination in the first and second entries respectively. Once you have all the entries entered then run

postmap /etc/postfix/<filename>

Whatever you do don’t put allmydomains.tld (or any of your other virtualaliasdomains) in either the mydestination or relay_domains config entries; it will break.