0

I have server1.com and server2.com both pointing to the same server. I wish to make all email sending to @server1.com and @server2.com going to the same mailbox in that particular server.

I searched around in the Internet and found out I need to configure virtual domain for the MTA no matter it's Sendmail or Postfix.

I wonder can I just use /etc/aliases for such purpose ? For example:

info@server1.com:  info
info@server2.com:  info

Or I can't do like that and have to use the setup described over here : Sendmail multi domain, Postfix multi domain ?

sylye
  • 241
  • 5
  • 13

2 Answers2

4

You cannot use /etc/aliases for virtual alias domains, so your syntax is wrong. Correct syntax is:

name: addr_1, addr_2, addr_3, . . .

Where name has to be the alias, the part before @. What's after the @depends on what is configured in mydestination (Postfix) or /etc/mail/local-host-names (Sendmail). There, you can have the list of your domain names.

Then, the addr_1 etc. can be local usernames, local /path/names, |commands or even :include: /path/names.

If the aliases are always the same on every domain, /etc/aliasesis just fine. If you need different destinations for info@example.com and info@example.org, you need to use virtual aliases. In Postfix it can be done with virtual_alias_maps.

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122
  • So on whether can we use `aliases` to achieve the multi mail domain setup is, whether the destination is the same or not. – sylye Dec 01 '15 at 08:07
  • If every domain has exactly the same mailboxes, it is possible. However, if you need even one exception, use virtual alias domains instead. – Esa Jokinen Dec 06 '15 at 12:22
2

YES

For postfix you need to ensure these two parameters

alias_maps = hash:/etc/aliases
mydestination = domain1.com domain2.com

As postfix has many similiarities with sendmail (including /etc/aliases support), then you can use same /etc/aliases. The sendmail equivalent setting for postfix-mydestination is putting the domains to /etc/mail/local-host-names. For example

# local-host-names - include all aliases for your machine here.
domain1.com
domain2.com

References:

masegaloeh
  • 17,978
  • 9
  • 56
  • 104
  • And to set the `aliases` correctly, I should just need to put one entry since `aliases` will not care what is the domain name after the '@', which mean by using `aliases`, I can only make all emails with the same name but different domain go to the same destination. [This answer](http://serverfault.com/a/738850/273982) has elaborated it quite well. – sylye Dec 01 '15 at 08:15
  • /etc/aliases does not support the example given in the original question, you cannot route info@domain1.com and info@domain2.com to two separate addresses with /etc/aliases. I just tried it and got "warning: name must be local." – Tom Boutell Jul 16 '22 at 22:18