Today’s topic is. Setting up the mail infrastructure on CentOS7. It is about setting up a system infrastructure that facilitates sending and receiving mail from any compatible mail agents. For ease of understanding, I am going to break down the core material as below.
- Mailbox: A central storage location – can be a local disk within the server – that stores every message sent by users.
- Mail Sender: When a message is being sent, it helps to route the emails to the central mailbox.
- Mail Receiver: Helps retrieve and retrieve messages from central mailboxes to local systems.
- Mail Agent: A place where users can compose and read mail.
Setting up the mail infrastructure on CentOS 7

Selected applications are;
- Mail Sender (SMTP) => Postfix
- Receive mail (IMAP/POP) => dovecot
- Mail Agent => Thunderbird
Configuring Postfix:
Installation of packages
yum install postfix
Reflecting desired parameters in main configuration file => /etc/postfix/main.cf
Note that, this file contains a bunch of configuration parameters, so be careful to only edit the ones mentioned below.
myhostname = mail.example.com mydomain = example.com myorigin = $mydomain inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mynetworks = 127.0.0.0/8, 10.0.0.0/24 home_mailbox = Maildir/ message_size_limit = 10485760 mailbox_size_limit = 1073741824
- myhostname => hostname of the server
- domain => domain-name of the server
- myorigin => domain-name associated with every message sent by the server (for example, @example.com)
- inet_interfaces => Enable the server to listen on all local interfaces
- mydestination => Server to which domain will be responsible for mail delivery.
- mynetworks => which network subnet is allowed access to send and receive mail.
- home_mailbox => Specify the path to the mail storage location
- message_size_limit => Limit an email size to 10M
- mailbox_size_limit => Limit a mailbox to 1G
Configuring Dovecot:
Package Installation
yum install dovecot
Unlike Postfix, Dovecot maintains different aspects of configurable options in different files. Let’s go through the essentials 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 it’s time to start the respective services and check the status of each.
1. systemctl start postfix 2. systemctl start dovecot 3. systemctl status postfix 4. systemctl status dovecot
Configuring FirewallD:
A firewall daemon should be configured, to allow SMTP, IMAP/POP traffic.
1. firewall-cmd --zone=public --add-port=25/tcp 2. firewall-cmd --zone=public --add-port=25/tcp --permanent 3. firewall-cmd --zone=public --add-port=110/tcp 4. firewall-cmd --zone=public --add-port=110/tcp --permanent 5. firewall-cmd --zone=public --add-port=143/tcp 6. firewall-cmd --zone=public --add-port=143/tcp --permanent
Configuring Thunderbird:
Installation and configuration are assumed to follow in a graphical environment.
Package installation
yum install epel-release Install Yam Thunderbird
Let us create a local user account for the demo
useradd --home-dir /home/user1 -m --shell /bin/bash user1 useradd --home-dir /home/user2 -m --shell /bin/bash user2
Create a user account with Thunderbird.
Once you launch Thunderbird, under Preferences > Account Settings it allows you to create a new user account with the following details.

Make sure to fill in the parameters as shown, but it’s important to change the server hostname for both IMAP/SMTP to what you have in your environment.
If you have two accounts, you can send/receive mail between them. Hopefully, now you set mail infrastructure on CentOS 7. Do you want to know how SMTP works? Then you can read this content.



