postfix and virtual hosts or domains tutorial
I have Apache 2 configured with VirtualHost’s. So I have my domains for example http://mydomain1.com and http://sampledomain.com running on my machine. What about mails now? What about postfix?
For arriving mail:
- Edit “/etc/postfix/main.cf” and add there:
virtual_alias_domains = mydomain1.com, sampledomain.com virtual_alias_maps = hash:/etc/postfix/virtual - Edit or add “/etc/postfix/virtual”:
@mydomain1.com user1 homer@sampledomain.com user2This means that all mail for domain mydomain1.com should be delivered to local user account user1 (/home/user1 or whatever). This means also that mails for homer@sampledomain.com will be delivered to local user account user2. - Execute:
cd /etc/postfix postmap virtual /etc/init.d/postfix restart
For departuring mail (mails sent form local accounts to the Internet):
- Edit “/etc/postfix/main.cf” and add there:
smtp_generic_maps = hash:/etc/postfix/generic -
Edit or add “/etc/postfix/generic”:
user1@ubuntu-1004-lucid-64-minimal user1@mydomain1.comSo mails sent from local account user1 will be sent into the Internet as user1@mydomain1.com. - Execute:
cd /etc/postfix postmap virtual /etc/init.d/postfix restart
Further information in here http://www.postfix.org/VIRTUAL_README.html#virtual_alias and in here http://www.postfix.org/ADDRESS_REWRITING_README.html#generic.