Config for mail server on Centos using Postfix and Dovecot
24 Oct 2014
I have setup mail servers so many times, each time I forget the correct config. So here’s a set of configs I just setup for a mail server on centos 6. It will act as future reference for me. I would be glad if it helps anyone else too.
Features
Sets up server on domain dev.pk
Rejects all outgoing or incoming to domains other than $mydestination
Check smtp_recipient_restrictions in postfix/main.cf
No smtp authentication for local network 192.168.1.0/24
IMAP on dovecot authenticated by usernames and passwords of linux system users (create them using useradd -m)
Mail saved in ~/mail
Aliases set via regex /test([0-9]*).(.*)@dev.pk/ $2@dev.pk in /etc/postfix/virtual_aliases
Run postmap /etc/postfix/virtual_aliases
Postfix
Here’s what’s changed from default in /etc/postfix/main.cf:
Alias file (/etc/postfix/virtual_alias):
Do postmap /etc/postfix/virtual_alias and service postfix restart after changing
Dovecot
/etc/dovecot/dovecot.conf:
Be sure to check mail_location and verify if your inbox is at /var/spool/mail/username