Steps for configuring Dovecot and Postfix for locally testing a webmail deployment (e.g. Roundcube Webmail).
Configure Hostname
1. Change the machine hostname (e.g. mail.testmail.com).
# hostname mail.testmail.com
2. Add or change the following line in the /etc/hosts file to point the configured hostname (e.g. mail.testmail.com) to the loopback address.
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 mail.testmail.com
Add Email User
3. Add and configure a user account for Dovecot IMAP access.
# useradd -m mailuser # passwd mailuser # and enter a password for the new user # mkdir /home/mailuser/Maildir # chown mailuser:mailuser /home/mailuser/Maildir
Install Packages
4. Install the dovecot and postfix packages.
# yum install dovecot postfix
Configure Dovecot
5. Add the following lines in the /etc/pam.d/dovecot file for the Dovecot PAM configuration.
auth required pam_unix.so account required pam_unix.so
6. Add or uncomment the following lines in the Dovecot configuration file /etc/dovecot/dovecot.conf.
protocols = imap pop3 lmtp listen = *, :: base_dir = /var/run/dovecot/
7. Uncomment and change the following line in the /etc/dovecot/conf.d/10-auth.conf file to allow plaintext authentication for testing purposes.
disable_plaintext_auth = no
8. Uncomment and change the following line in the /etc/dovecot/conf.d/10-mail.conf file to set the email storage location.
mail_location = maildir:~/Maildir
9. Uncomment the following lines in the /etc/dovecot/conf.d/10-master.conf file to configure the IMAP listening port.
service imap-login {
inet_listener imap {
port = 143
}
...
}
10. Uncomment and change the following line in the /etc/dovecot/conf.d/15-lda.conf file to set the postmaster email address.
postmaster_address = postmaster@mail.testmail.com
11. Uncomment the following lines in the /etc/dovecot/conf.d/auth-system.conf.ext file to configure Dovecot to use PAM for authentication.
passdb {
driver = pam
...
args = dovecot
}
Configure Postfix
12. Uncomment the following line in the /etc/postfix/main.cf file to configure Postfix to use the previously set hostname.
inet_interfaces = $myhostname, localhost
13. Comment out the following line in the /etc/postfix/main.cf file.
#inet_interfaces = localhost
14. Add the following line in the /etc/postfix/main.cf file to configure Postfix to use Dovecot LDA for mail delivery.
mailbox_command = /usr/libexec/dovecot/dovecot-lda -f "$SENDER" -a "$RECIPIENT"
Start Dovecot and Postfix
15. Start Dovecot.
# /etc/init.d/dovecot start
16. Start Postfix.
# /etc/init.d/postfix start
Install Webmail
17. Install the webmail package (e.g. Roundcube Webmail).
Troubleshooting
18. For troubleshooting, error messages will be in the /var/log/maillog file.
References
[1] http://wiki2.dovecot.org/
[2] http://wiki2.dovecot.org/PasswordDatabase/PAM
[3] http://wiki2.dovecot.org/LDA/Postfix