Sunday, January 11, 2009

Linux: Setting up Multi domain Mail server with Postfix and Dovecot

This article describes how to setup Dovecot pop3/imap server to get the mails from virtual mailboxes to your mail client.


Among the various methods of pop/imap authentication, we will be using text files method. Read the manpagesof dovecot to better understand it.

Following is a sample dovecot.conf file , we’ll not use SSL.

base_dir = /var/run/dovecot/
protocols = imap pop3 imaps pop3s
ssl_disable = yes
log_path = /var/log/dovecot
info_log_path = /var/log/dovecot.info
login_dir = /var/run/dovecot/login
login_chroot = yes
login = imap
login_executable = /usr/lib/dovecot/imap-login
login_user = dovecot
login = pop3
login_executable = /usr/lib/dovecot/pop3-login
verbose_ssl = no
valid_chroot_dirs = /var/spool/vmail
default_mail_env = maildir:/var/spool/vmail/%d/%n
imap_executable = /usr/lib/dovecot/imap
pop3_executable = /usr/lib/dovecot/pop3
auth = default
auth_mechanisms = plain digest-md5
auth_userdb = passwd-file /etc/dovecot/users
auth_passdb = passwd-file /etc/dovecot/passwd
auth_executable = /usr/lib/dovecot/dovecot-auth
auth_user = root
auth_verbose = yes

We are using Dovecot to support imap and pop3.

The default_mail_env line describes the path of the mailbox. Here “%d” means domain and “%n” means username.
Thus maildir for jay@mydomain.com becomes “/var/spool/vmail/mydomain1.com/jay”

Now let’s have a look at how we can authenticate the users.

“auth_mechanisms = plain digest-md5” states that two methods plain and digest-md5 are allowed to use.
“auth_userdb = passwd-file /etc/dovecot/users” stores the username portion while “auth_passdb = passwd-file /etc/dovecot/passwd” stores password for them.

Following is an example format of these files.
Users:

jay@mydomain1.com::900:900::/var/spool/vmail/domain1.com/:/bin/false::


Passwd:

jay@mydomain1.com:put encrypted password here

We are using MD5 hash encrypted password here. You can use “mkpasswd” command to generate the MD5 password.


This finishes the Virtual Domain setup using postfix and Dovecot.

No comments:

Post a Comment