Setup Mail Server On Centos 7
Setup Mail Server On Centos 7
Setup Mail Server On Centos 7
This article helps you to install and configure basic mail server on Centos 7. Here i have used
Postfix for SMTP, Dovecot for POP/IMAP and Dovecot SASL for SMTP AUTH.
Before proceeding please make sure you have assigned static IP for the server and have internet
connectivity for installing packages.
Installing packages
Step 1 » Assign hostname for the server using the below command.
[root@krizna ~]# hostnamectl set-hostname mail.krizna.com
Postfix configuration
[root@krizna ssl]# openssl x509 -req -days 365 -in server.csr -signkey server.key
-out server.crt
and add below lines at the end of the file. change myhostname and mydomain values with
yours and home_mailbox value to your desired directory. Here it will store mails in the users
home directory (Eg: /home/john/mail ).
myhostname = mail.krizna.com
mydomain = krizna.com
myorigin = $mydomain
home_mailbox = mail/
mynetworks = 127.0.0.0/8
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions =
permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_key_file = /etc/postfix/ssl/server.key
smtpd_tls_cert_file = /etc/postfix/ssl/server.crt
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
Step 6 » Open /etc/postfix/master.cf file, add the below lines after “smtp inet n – n – – smtpd”
line.
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
Step 9 » Postfix configuration is over. Now restart both postfix and dovecot services and enable
auto start.
[root@mail ~]# systemctl restart postfix
Step 10 » Add the firewall rules to allow 25, 587 and 465 ports.
[root@mail ~]# firewall-cmd --permanent --add-service=smtp
Trying 172.27.0.51...
Connected to mail.krizna.com.
Dovecot configuration
Check the connectivity for the ports 110,143,993 and 995 using telnet.
User creation
Mail server is ready now, Configure user in your mail client and test send/receive.