Wednesday, May 5, 2010

Setup Postfix Virtual Domains

In this article, I assume that postfix has been already setup on the server and running. Here I am going to describe how to setup postfix virtual domains using hash tables. The mailboxes will also be separate accounts and not unix system accounts.

Edit /etc/postfix/main.cf file and add the following parameters.

1.  virtual_mailbox_domains=/etc/postfix/vdomains
    Here, /etc/postfix/vdomains is the file which contains names of the domains to be setup virtually and handled by postfix. Remember to enter one domain per line.

2. virtual_mailbox_base=/home/vmail
    It tells the postfix system about the base directory of the mail store. It can be any directory on the unix system.

3. virtual_mailbox_maps=hash:/etc/postfix/vmaps
   Here I have created a lookup file that maps email addresses to their mailboxes. A virtual mailbox will looks like the following.
      test@test.com                              test.com/test
      webmaster@mydomain.com        mydomain.com/webmaster
  Remember to create the hash table of the file using the following command:
     #postmap /etc/postfix/vmaps


4. Setup mailbox file ownership using following directives in main.cf.
     virtual_uid_maps= ( check /etc/passwd for uid )
     virtual_gid_maps= ( check /etc/group for gid )

5. Create required folders under /home/vmail,  e.g. for domain mydomain.com and user webmaster, the directory structure will looks like the following:
     #mkdir  /home/vmail/mydomain.com
     #mkdir  /home/vmail/mydomain.com/webmaster
     #mkdir -p  /home/vmail/mydomain.com/webmaster/{cur,new}


6. Change ownership and folder permissions.
    #chown  -R postfix.postfix  /home/vmail/mydomain.com
    #chmod  -R  775  /home/vmail/mydomain.com


7. Reload postfix system to implement the changes done above.
    #postfix reload


Thats it! Your postfix system has been configured to support multiple domains now.

Thanks!!!
  

No comments:

Post a Comment