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/ 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.                    
  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
     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 and user webmaster, the directory structure will looks like the following:
     #mkdir  /home/vmail/
     #mkdir  /home/vmail/
     #mkdir -p  /home/vmail/{cur,new}

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

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.


No comments:

Post a Comment