1

I have one server hosting several domains - one main domain and several alias domains.

Domains

main.com
alias1.com
alias2.com

I use the domain name registra's (Gandi.net) email service for the main domain. I would like all emails to the alias domains to be forwarded to the email service for the main one. Which I think means just forward them to @main.com

I'm struggling with Postfix (and maybe DNS?) settings.

DNS

main mx records
    fb.mail.gandi.net      <-- Gandi's settings - I'm sure they're correct  
    spool.mail.gandi.net

alias1 mx records
    mail.alias1.com

alias2 mx records
    mail.alias2.com

All domains have an A/AAAA record for mail.[domain].com which points to the server IP address.

I also have a 4th domain (superdomain.com) which I am using as the server's hostname. It's DNS records look the same as main.com.

Using this page from Postfix - http://www.postfix.org/VIRTUAL_README.html - it looks like I can use virtual alias domains

main.cf settings

myhostname = mail.superdomain.com
mydestination = pluto.superdomain.com localhost.superdomain.com localhost $myhostname localhost.$mydomain
virtual_alias_domains = alias1.com alias2.com
virtual_alias_maps = hash:/etc/postfix/virtual

relay_domains = main.com

virtual file contents

@alias1.com @main.com
@alias2.com @main.com

The settings might look a little odd. I've tried quite a few combinations thus far :-P. The structure of the virtual file comes from the answer to How to redirect all mail from one domain to another in Postfix? [serverfault.com]

Based on the bounce backs from test emails - I seem to be getting "connection refused" results.

Any ideas or tips?

1 Answer 1

1

It was a firewall (iptables) issue! At some point I changed the firewall and completely forgot :-P

For those it might help doing this in the future, the final configuration for doing this was:

main mx records
    fb.mail.gandi.net
    spool.mail.gandi.net

alias1 mx records
    mail.superdomain.com

alias2 mx records
    mail.superdomain.com

main.cf settings

myhostname = mail.superdomain.com
mydomain = superdomain.com
mydestination = pluto.superdomain.com, localhost.superdomain.com, localhost
virtual_alias_domains = alias1.com alias2.com

virtual file contents

@alias1.com @main.com
@alias2.com @main.com

Extra firewall/iptables rule

-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT

The gist of the settings is:

  • the mx mail records tell mail servers on the Internet (not yours) which IP address they should send their mail to. Each of the domains had an A record for mail.[domain].com which resolved to the server IP address. I think it could have been left as mail.alias[x].com but it seemed neater to make it mail.superdomain.com as superdomain is conceptually the mail servering domain.
  • mydestination specifies what domains postfix can deliver to on this server - that is, locally
  • virtual_alias_domains specifies where postfix is allowed to forward (alias) mail onto

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .