11.9 C

Setting up Mail Infrastructure on top of CentOS7

This is about setup a system infrastructure that facilitate sending & receiving mails from any compatible mail agents. To ease of understanding, I am going to break up the key component as below.

  1. Mail Box: A central storage location – could be a local disk within the server – that store every message send by users.
  2. Mail Sender: When a message is being sent, this helps to route mails to the central MailBox.
  3. Mail Receiver: Helps to retrieve and get messages into the local system from the central Mailbox
  4. Mail Agent: A place where user can compose & read mails.


The selected Applications are;

  • Mail Sender (SMTP) => Postfix
  • Mail Receive (IMAP/POP) => Dovecot
  • Mail Agent => Thunder Bird


Configuring Postfix:

01. Package Installation

yum install postfix


02. Reflecting the desired parameters in main configuration file => /etc/postfix/main.cf
Note that this file is having bunch of configuration parameter, so be mindful to edit only those are mentioned below.

myhostname = mail.example.com        
mydomain = example.com               
myorigin = $mydomain                  
inet_interfaces = all                 
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain        
mynetworks =,    

home_mailbox = Maildir/               
message_size_limit = 10485760         
mailbox_size_limit = 1073741824

myhostname => hostname of the server
domain => domain-name of the server
myorigin => the domain-name append to every message that are sent off by the server (for example, @example.com)
inet_interfaces => enable server to listen from all local interfaces
mydestination => which domain the server will be responsible for mail delivery.
mynetworks => from which network subnets to allow access for sending & receiving mails.
home_mailbox => specify path of the mail storing location
message_size_limit => limit an email size for 10M
mailbox_size_limit => limit a mailbox for 1G


Configuring Dovecot:

01. Package Installation

yum install dovecot


02. Unlike Postfix, Dovecot maintain different aspect of configurable option in different files. Let go through the once that is important for this demo.

=> vim /etc/dovecot/dovecot.conf

protocols = imap pop3 lmtp            
listen = *


=> vim  /etc/dovecot/conf.d/10-auth.conf

auth_mechanisms = plain login
disable_plaintext_auth = no


=> vim /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir


=> vim  /etc/dovecot/conf.d/10-master.conf

# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix


=> vim /etc/dovecot/conf.d/10-ssl.conf

ssl = no


Now its time to start the respective service and check the status each.

systemctl start postfix
systemctl start dovecot

systemctl status postfix
systemctl status dovecot



Configuring FirewallD:

01. To allow SMTP, IMAP/POP traffic, firewall daemon should be configured.

firewall-cmd --zone=public --add-port=25/tcp
firewall-cmd --zone=public --add-port=25/tcp --permanent
firewall-cmd --zone=public --add-port=110/tcp
firewall-cmd --zone=public --add-port=110/tcp --permanent
firewall-cmd --zone=public --add-port=143/tcp
firewall-cmd --zone=public --add-port=143/tcp --permanent


Configuring Thunderbird:

Following installation and configuration suppose to be in a graphical environment.

01. Package Installation

yum install epel-release
yum install thunderbird


02. Lets create local user accounts for our demo

useradd --home-dir /home/user1 -m --shell /bin/bash user1
useradd --home-dir /home/user2 -m --shell /bin/bash user2


03. Create user account on Thunderbird.

Once you launch the Thunderbird, Under Preferences > Account Setting it allows to create new user account with following details.

Make sure to fill the parameters as in the figure, but its important to change the Server hostname for both the IMAP/SMTP to what you have in your environment.

Once you have two account, you can send/receive mails in between.

“Hope this has been informative for you”


- Advertisement -


Please enter your comment!
Please enter your name here

Donate to Osradar

Latest article