TP Mail
TP Mail
Postfix – Dovecot
Services et Administration des Réseaux
Esprit 2021/2022
CentOS 7 –install & configure Postfix – Dovecot
Services et Administration des Réseaux
Introduction:
There are many different scenarios and combinations that can be used when setting up an email
server (far to many to cover here), so this TP makes some basic choices for you, such as the
software we will use (postfix and dovecot). Other options are required to be altered by the user,
such as your network addresses and domain names.
This TP uses postfix as the mail transport agent (MTA), as opposed to sendmail, the default MTA
for CentOS 5 (postfix is the default in CentOS 6). Dovecot is used to allow users to access their
email by either imap or pop protocols. We assume a domain name of esprit.com which should
be changed by the reader and can be either a real domain name for a fully qualified email server
or a fake domain name if you only wish to implement an internal mail server.
Objectifs:
✓ Add user accounts (user1 and unser2).
✓ Installing the MTA and MDA services.
✓ Configuring Postfix and Dovecot software module.
✓ Testing
#useradd –m user1
#passwd user1
#useradd –m user2
#passwd user2
1
Step 2 : Install Postfix server
Before installing postfix, you should check if it is already installed because postfix is the
default MTA in CentOS 7. But if Postfix is not, use the below command to install it
[root@server ~]# yum -y install postfix
By default Port number 25, 110 and 143 are closed so we need to allow access throw those
ports
Enabling access on port SMPT (tcp/25), POP3 (tcp/110), and IMAP (tcp/143) in the iptables.
Open the postfix config file /etc/postfix/main.cf. Find the below lines and edit them as shown
below.
[root@server ~]# nano /etc/postfix/main.cf
#line no 99 - uncomment
myorigin = $mydomain
Now let’s take a look at each setting it turn to understand what we've just done:
myhostname: is the host name of the system ( the system is called mail or mail.esprit.com).
mydomain: is the domain name for the email server (it can be a real or fake domain name).
myorigin: is the domain name that locally-posted email appears to have come from and is
delivered to.
inet_interfaces: sets the network interfaces that Postfix can receive mail on. These need to
include at least localhost and the local domain.
mydestination: is the list of domains that will be delivered to ( this server is the final
destination for email addressed to these domains).
mynetworks: is a list of trusted IP addresses that may send or relay mail through the server.
CentOS 7 –install & configure Postfix – Dovecot |
Users attempting to send email through the server originating from IP addresses not listed
here will be rejected.
relay_domains: is a list of destination domains this system will relay mail to. By setting it to
be blank we ensure that our mail server isn't acting as an open relay for untrusted networks.
home_mailbox: sets the path of the mailbox relative to the users home directory and also
specifies the style of mailbox to be used. Postfix supports both Maildir and mbox formats and
readers are encouraged to read up on the merits of each for themselves.
3
Step 5 : Start the services
After finishing the configuration we should start the service and keep it on
quit
221 2.0.0 Bye
Connection closed by foreign host.
Check Mail
Navigate to the user mail directory and check for the new mail.
4
by esprit.com (Postfix) with ESMTP id 117113FF18
for <user1>; Thu, 7 Feb 2013 17:05:32 +0530 (IST)
Message-Id: <[email protected]>
Date: Thu, 7 Feb 2013 17:05:32 +0530 (IST)
From: [email protected]
To: undisclosed-recipients:;
test
Postfix working now.
Step 7 : Install Dovecot
Dovecot is used to allow users to access their email by either imap or pop protocols.
[root@server ~]# yum -y install dovecot
Open the dovecot config file /etc/dovecot/dovecot.conf. Find and uncomment the line as
shown below.
protocols: specifies the protocols available to users to access their email. Dovecot supports
imap(s) and pop3(s), and any or all may be used.
mail_location: specifies the format and location of each users mailbox. Here we see we are
using maildir format and each user has their mailbox located at ~/Maildir. Examples for
mbox format are provided in the configuration file.
Required tests:
After testing postfix and dovecot with user1 now try to send a Mail from user 1 to user 2 and
check if user2 receives the mail.
Mail Clients’Setting
6
Configure for your Mail Client on your PC. This example shows with Mozilla Thunderbird.
[1] Run Thunderbird and Click [Create a new account] - [EMAIL].
[6] If email account setup normally, it's possible to send or receive emails like follows.