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:

  1. Edit “/etc/postfix/main.cf” and add there:
          virtual_alias_domains = mydomain1.com, sampledomain.com
          virtual_alias_maps = hash:/etc/postfix/virtual
        
  2. Edit or add “/etc/postfix/virtual”:
          @mydomain1.com user1
          homer@sampledomain.com user2
        
    This 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.
  3. Execute:
          cd /etc/postfix
          postmap virtual
          /etc/init.d/postfix restart
        

For departuring mail (mails sent form local accounts to the Internet):

  1. Edit “/etc/postfix/main.cf” and add there:
     
          smtp_generic_maps = hash:/etc/postfix/generic
        
  2. Edit or add “/etc/postfix/generic”:
          user1@ubuntu-1004-lucid-64-minimal user1@mydomain1.com
        
    So mails sent from local account user1 will be sent into the Internet as user1@mydomain1.com.
  3. 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.

Posted by wojtek Fri, 23 Jul 2010 11:04:00 GMT




Comments

Leave a response

Leave a comment