CentOS 7.x postfix email virtualhosting

From Notes_Wiki

Home > CentOS > CentOS 7.x > Email configuration > Postfix configuration > CentOS 7.x postfix email virtualhosting

It is possible to setup postfix server for multiple domains (eg sbarjatiya.com, pbarjatiya.com, etc.) on a single server. To perform postfix email virtualhosting use following steps:

  1. Edit /etc/postfix/main.cf as follows
    1. Set myhostname = localhost
    2. Add following lines at bottom
      virtual_mailbox_domains = /etc/postfix/vhosts.txt
      virtual_alias_maps = hash:/etc/postfix/valias.txt
  2. Create /etc/postfix/vhosts.txt and write one domain name on each line. For example
    sbarjatiya.com
    pbarjatiya.com
  3. Create /etc/postfix/valias.txt. Write incoming and forwarding address one on each line. For domain forwarding mention incoming address as @domain.
    saurabh@sbarjatiya.com barjatiya.saurabh@gmail.com
    spam@sbarjatiya.com saurabhisgood@yahoo.com
    @sbarjatiya.com check-when-free@gmail.com
    parag@pbarjatiya.com parag@gmail.com
    priyanka@pbarjatiya.com priyanka@gmail.com
    @pbarjatiya.com check-when-free@gmail.com
  4. Create map using
    cd /etc/postfix
    postmap valias.txt
  5. Reload postfix using
    systemctl reload postfix
  6. Test by sending various emails to different domains. You can check queue on server using "postqueue -p" in case email is not delivered. Also check /var/log/maillog for troubleshooting.


Refer;


Home > CentOS > CentOS 7.x > Email configuration > Postfix configuration > CentOS 7.x postfix email virtualhosting