How to Postfix , Dovecot (CentOS 6.x)
Install required software postfix, dovecot and saslauth for smtp authentication
[root@mail /]#yum -y install postfix dovecot saslauthd
Start required services to support mail services
[root@mail /]#/etc/init.d/postfix start
Starting postfix: [ OK ]
[[root@mail ~]# /etc/init.d/saslauthd start
Starting saslauthd: [ OK ]
[root@mail ~]# /etc/init.d/dovecot start
Starting Dovecot Imap: [ OK ]
Make sure the required services start during the boot process
[root@mail /]#/ chkconfig postfix on
[root@mail /]#/ chkconfig dovecot on
[root@mail /]#/ chkconfig saslauthd on
Postfix configuration
[root@mail /]#nano /etc/postfix/main.cf
inet_interfaces = all uncomment line 113
#inet_interfaces = localhost comment out line 116
mydestination = $myhostname, localhost.$mydomain, localhost, yourdomais.com (add your domain(s) to mydestination) line 164
relayhost = yourisp.relay.com uncomment if required line 316
At the end of the configuration file add the following:
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_path = smtpd
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_type = cyrus
smtpd_sasl_security_options = noanonymous
crtl+o File Name to Write: /etc/postfix/main.cf (save the changes)
crtl+x (exit)
Restart postfix
[root@mail /]#/etc/init.d/postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
Verify that Postfix is working correctly
[root@mail ~]# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 yuourdomaim.com ESMTP Postfix
ehlo
501 Syntax: EHLO hostname
ehlo locathost
250-yourdomain.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
Dovecot configuration
root@mail /]#nano /etc/dovecot/conf.d/10-mail.conf
mail_location = mbox:~/mail:INBOX=/var/mail/%u uncomment line 25
crtl+o File Name to Write: /etc/dovecot/conf.d/10-mail.conf (save the changes)
crtl+x (exit)
root@mail /]#nano /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no uncomment and change to yes Line 9
auth_mechanisms = plain login uncomment and add login Line 97
crtl+o File Name to Write: /etc/dovecot/conf.d/10-auth.conf
crtl+x (exit)
Restart postfix to activate changes
[root@mail /]# /etc/init.d/dovecot restart
Stopping Dovecot Imap: [ OK ]
Starting Dovecot Imap: [ OK ]
Modify firewall rules to allow mail traffic
[root@mail /]# iptables -A INPUT -m state --state NEW -p tcp --dport 25 -j ACCEPT
[root@mail /]# iptables -A INPUT -m state --state NEW -p tcp --dport 110 -j ACCEPT
[root@mail /]# iptables -A INPUT -m state --state NEW -p tcp --dport 143 -j ACCEPT
[root@mail /]# iptables -A INPUT -m state --state NEW -p tcp --dport 993 -j ACCEPT
[root@mail /]# iptables -A INPUT -m state --state NEW -p tcp --dport 995 -j ACCEPT
[root@mail /]# /etc/init.d/iptables save
[root@mail /]# /etc/init.d/iptables restart