Can I use /etc/aliases for multiple domain mail server?

5,385

Solution 1

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:

Solution 2

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 [email protected] and [email protected], you need to use virtual aliases. In Postfix it can be done with virtual_alias_maps.

Share:
5,385

Related videos on Youtube

sylye
Author by

sylye

GNU/linux and all others FOSS technology lover.

Updated on September 18, 2022

Comments

  • sylye
    sylye almost 2 years

    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:

    [email protected]:  info
    [email protected]:  info
    

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

  • sylye
    sylye over 8 years
    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 has elaborated it quite well.
  • Esa Jokinen
    Esa Jokinen over 8 years
    If every domain has exactly the same mailboxes, it is possible. However, if you need even one exception, use virtual alias domains instead.