LAB 3 Messagerie
LAB 3 Messagerie
LAB 3 Messagerie
Esprit 2023/2024
1
Ubuntu 22.04 –install & configure
Postfix – Dovecot
Services et Administration des Réseaux
Introduction:
Setting up a robust and reliable email infrastructure is a fundamental requirement for modern
communication. In this lab, we will delve into the installation and configuration of an email server on
Ubuntu 22.04, with the domain name montpdomain.lan
Our email server will utilize two critical components: the Mail Transfer Agent (MTA) and the Mail
Delivery Agent (MDA). These components play distinct yet complementary roles in ensuring the
smooth flow of electronic mail.
MTA (Mail Transfer Agent): Think of the MTA as the postal service of the digital world. It is responsible
for routing and transferring emails from the sender's client to the recipient's server. Our choice for this
role is Postfix, a highly efficient and secure MTA that has become a standard in the industry.
MDA (Mail Delivery Agent): Once emails arrive at the recipient's server, they need to be sorted and
placed into the correct mailbox. This is where the MDA comes into play. We will use Dovecot as our
MDA, which provides robust support for the Internet Message Access Protocol (IMAP) and Post Office
Protocol (POP3), allowing users to access their emails seamlessly.
By following the steps in this lab manual, you will develop a comprehensive understanding of how to
configure these components, ultimately constructing a functional email server tailored to your
communication needs. Let's begin the process of setting up your email infrastructure with Postfix and
Dovecot on Ubuntu 22.04!
Objectifs:
✓ Adduseraccounts(user1 and user2).
✓ Installing the MTA and MDA services.
✓ Configuring Postfix and Dovecot software module.
✓ Testing
Open the postfix config file /etc/postfix/main.cf. Find the below lines and edit them as shown
below.
To set the mailbox format, you can edit the configuration file directly, the configuration parameters
will be stored in /etc/postfix/main.cf file.
user1: user1@montpdomain.lan
user2: user2@montpdomain.lan
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.
4
Step 6 : Start the services
After finishing the configuration we should start the service and keep it on
#sudo systemctl restart postfix
Check Mail
Navigate to the user mail directory and check for the new mail.
root@machine-serveur:/home/user2/Maildir/new# cd /home/user2/Maildir/new
root@machine-serveur:/home/user2/Maildir/new# ls
1694966621.V803Ie0ac5M630309.machine-serveur
root@machine-serveur:/home/user2/Maildir/new# cat
1694966621.V803Ie0ac5M630309.machine-serveur
Return-Path: <user1@montpdomain.lan>
X- Original-To: user2@montpdomain.lan
Delivered-To: user2@montpdomain.lan
Received: from localhost (localhost [127.0.0.1])
by mail.montpdomain.lan (Postfix) with ESMTP id 3642480116
for <user2@montpdomain.lan >; Sun, 17 Sep 2023 17:03:15 +0100 (WAT)
Message-Id: <20230917160332.3642480116@mail.montpdomain.lan >
Date: Sun, 17 Sep 2023 17:03:15 +0100 (WAT)
From: user1@montpdomain.lan
test
5
Postfix working now.
Step 8 : Install Dovecot
Dovecot is used to allow users to access their email by either imap or pop protocols.
#sudo apt-get install postfix dovecot-imapd dovecot-pop3d
#
#gedit /etc/dovecot/dovecot.conf
#line 30:uncomment
listen = * , ::
#line 24:uncomment
!include_try /usr/share/dovecot/protocols.d/*.protocol
Open the file /etc/dovecot/conf.d/10-mail.conf and uncomment the line as shown below.
# gedit /etc/dovecot/conf.d/10-mail.conf
"Make sure to have only one mail_location directive uncommented in the configuration."
# gedit /etc/dovecot/conf.d/10-auth.conf
# gedit /etc/dovecot/conf.d/10-master.conf
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
6
}
Restart the dovecot service.
# sudo systemctl restart dovecot
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
Configure for your Mail Client on your PC. This example shows with Mozilla Thunderbird.
[1] Run Thunderbird and Click [Create a new account] - [EMAIL].
8
9
[5] If email account setup normally, it's possible to send or receive emails like follows.
safa.hachani@esprit.tn
10