Setup SMTP mail server on centos 7 and IP Rotation Print

  • 2

This article will 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.

Setup mail server on centos 7

Installing packageswmirchi

Step 1 » Assign hostname for the server using the below command.
[root@wmirchi ~]# hostnamectl set-hostname mail.wmirchi.com

Step 2 »
 Make a host entry with your IP in /etc/hosts file.
100.00.00.01 mail.wmirchi.com

Step 3 »
 Now start installing packages.
[root@wmirchi ~]# yum -y install postfix dovecot

After package installation continue with postfix configuration.

Postfix configuration

First create SSL certificate for encryption.

Step 4 »
 Follow the below steps one by one for creation.
[root@mail ~]# mkdir /etc/postfix/ssl
[root@mail ~]# cd /etc/postfix/ssl
[root@wmirchi ssl]# openssl genrsa -des3 -out server.key 2048
[root@wmirchi ssl]# openssl rsa -in server.key -out server.key.insecure
[root@wmirchi ssl]# mv server.key server.key.secure
[root@wmirchi ssl]# mv server.key.insecure server.key
Leave blank for A challenge password [] value in the below step.
[root@wmirchi ssl]# openssl req -new -key server.key -out server.csr
[root@wmirchi ssl]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt


Step 5 »
 Now open /etc/postfix/main.cf file for changes.
Find and uncomment the below lines.
#inet_interfaces = localhost #---> line no 116
#mydestination = $myhostname, localhost.$mydomain, localhost #--> line no 164

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 ).


Was this answer helpful?

« Back