CentOS 7.x postfix email virtualhosting
From Notes_Wiki
<yambe:breadcrumb>CentOS_7.x_postfix_configuration|CentOS 7.x postfix configuration</yambe:breadcrumb>
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:
- Edit /etc/postfix/main.cf as follows
- Set myhostname = localhost
- Add following lines at bottom
- virtual_mailbox_domains = /etc/postfix/vhosts.txt
- virtual_alias_maps = hash:/etc/postfix/valias.txt
- Create /etc/postfix/vhosts.txt and write one domain name on each line. For example
- sbarjatiya.com
- pbarjatiya.com
- 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
- Create map using
- cd /etc/postfix
- postmap valias.txt
- Reload postfix using
- systemctl reload postfix
- 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;