Professional Documents
Culture Documents
Service de messagerie
postfix/Dovecot
contact@ordinatous.com
Table des matières
1. 1.Présentation............................................................................................................................................1
2. 2.Installation..............................................................................................................................................1
Il est possible de relancer cette partie de l'installation avec le gestionnaire de paquets dpkg.......................2
Sudo dpkg-reconfigure postfix......................................................................................................................2
2.1.Monitoring..........................................................................................................................................3
3. 3.Configuration.........................................................................................................................................3
3.1.Reseau................................................................................................................................................3
3.2.FQDN.................................................................................................................................................3
3.3.Hostname............................................................................................................................................4
3.4.DNS....................................................................................................................................................4
a)Relancer le service............................................................................................................................5
3.5.Test.....................................................................................................................................................5
3.6.Installation dovecot............................................................................................................................6
a)Test...................................................................................................................................................7
b)Test...................................................................................................................................................8
c)Connexion active..............................................................................................................................9
d)Anti-spam/anti-virus.......................................................................................................................10
e)Test..................................................................................................................................................11
amavis............................................................................................................................................11
Spamassassin..................................................................................................................................11
Status du service spamassassin......................................................................................................12
f)Client « lourd »...............................................................................................................................12
Configuration du compte...............................................................................................................13
g)Squirrelmail....................................................................................................................................15
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
1. Présentation
A priori Postfix n’a d’autre prétention que de se proposer
comme alternative à sendmail.
Postfix est open source, il est disponible sur le site ,
est le cadeau d'un ingénieur de chez Google :
Wietse Zweitze Venema
Contact information is given at the end of this document.
Click here if you need to know how I pronounce my name.
Current life
I am a Google software engineer, working at the New York
office. After 18 years with IBM, including many of the best
years in my career, I decided that it was time for a change.
Many people know my name from the Postfix open source mail
server, and from the Coroner's Toolkit, written with Dan
Farmer, primarily for the post-mortem analysis of computer
break-ins. I wrote these at the IBM Thomas J. Watson
Research Center, in the USA, where I worked until 2015.
2. Contexte du document
contact@ordinatous.com 1/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
2.2. Principe
Schéma de l’envoi d’un courriel :
3. Installation
Procédure habituelle sous unix-like, Debian et dérivées :
contact@ordinatous.com 2/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
contact@ordinatous.com 3/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
4.Configuration
4.1. Reseau
Ensuite penser à fixer l'IP de la machine en modifiant le fichier :
/etc/network/interface
4.2. FQDN
Modifier le fichier :
# vim /etc/hosts
127.0.0.1 localhost
127.0.1.1 mail
172.25.3.34 mail.grp3.info-msj.net mail
4.3. Hostname
Bien vérifier le nom de la machine dans /etc/host, le nom qui avait été
attribué à l'installation « postfix » ne correspond pas on le modifie donc
en « mail »
# vim /etc/hostname
contact@ordinatous.com 4/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
4.4. DNS
Vérifier et/ou modifier alors les enregistrements DNS, dans
notre serveur DNS.
Enregistrement MX
cat /etc/bind/db.grp3.info-msj.net
$ORIGIN grp3.info-msj.net.
$TTL 1600
@ IN SOA ns1.grp3.info-msj.net. @root.grp3.info-msj.net. (
2013112801 ;Serial
604800 ;Refresh
86400 ;Retry
2419200 ;Expire
604800 ); Negative Cache TTL
@ IN NS srv-debian.grp3.info-
msj.info-msj.net.
@ IN MX 10
mail.grp3.info-msj.net.
Srv-debian IN A 172.25.3.107
mail IN A 172.25.3.34
www IN A 172.25.3.107
rtfm IN A 172.25.3.113
www3 IN A 172.25.3.123
webmail IN CNAME mail
$ORIGIN 3.25.172.in-addr.arpa.
$TTL 1600
@ IN SOA ns1.grp3.info-msj.net. @root.grp3.info-
msj.net. (
2013112801 ;Serial
604800 ;Refresh
86400 ;Retry
2419200 ;Expire
604800 ) ;Negative Cache TTL
@ IN NS srv-debian.grp3.info-msj.net.
contact@ordinatous.com 5/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
a) Relancer le service
Aprés avoir modifier les fichiers de configuration il faut
penser à « recharger » puis « relancer » et finalement vérifier
le « status » du service.
4.5. Test
contact@ordinatous.com 6/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
Code Signification
220 Premier code envoyé par le serveur lorsque la connexion s'est effectuée avec succès.
250 Confirmation de commande acceptée.
Réponse à la commande DATA. Le serveur attend les données du corps du message.
354 Le client indique la fin du message par un point seul sur une ligne :
<CR><LF>.<CR><LF>
Échec temporaire au niveau de la connexion. Il se peut que le serveur soit surchargé,
421 qu'il limite le nombre de connexions en provenance d'une même adresse IP ou que le
service soit indisponible.
452 Échec temporaire : nombre de destinataires maximum atteint.
Échec permanent. La boîte aux lettres n'existe pas ou l'adresse du destinataire est
550
invalide.
Échec permanent au niveau de la connexion : utilisé à la place du code 220 pour les
554
hôtes sur liste noire.
b) POP IMAP
Le POP permet la récupération des messages en local sur la
machine cliente.
Les messages seront alors absent du serveur distant, ceci peu
présenter un avantage ou non suivant les circonstances, il peut
être nécessaire de disposer des messages en local dans le cas ou
l’utilisateur se retrouverait sans connexion.
contact@ordinatous.com 7/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
/etc/dovecot/local.conf
Et ajouter :
contact@ordinatous.com 8/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
a) Test
Test sur le protocole imap
telnet localhost imap
Trying ::1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID
ENABLE IDLE AUTH=PLAIN] Dovecot Serveur en service
Trying ::1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot Serveur en service
contact@ordinatous.com 9/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
b) Test
telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mail.grp3.info-msj.net ESMTP Postfix (Debian/GNU)
helo srv-debian.grp3.info-msj.net
250 mail.grp3.info-msj.net
mail from:ordinatous@grp3.info-msj.net
250 2.1.0 Ok
rcpt to:ordinatous@grp3.info-msj.net
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
blableblibloblu
.
250 2.0.0 Ok: queued as 537333F
quit
221 2.0.0 Bye
Connection closed by foreign host.
cat
/home/ordinatous/Maildir/new/1452505828.V801I2088bM395967.mail
Return-Path: <ordinatous@grp3.info-msj.net>
X-Original-To: ordinatous@grp3.info-msj.net
Delivered-To: ordinatous@grp3.info-msj.net
Received: from srv-debian.grp3.info-msj.net (localhost
[IPv6:::1])
by mail.grp3.info-msj.net (Postfix) with SMTP id 537333F
for <ordinatous@grp3.info-msj.net>; Mon, 11 Jan 2016
10:47:58 +0100 (CET)
Message-Id: <20160111094959.537333F@mail.grp3.info-msj.net>
Date: Mon, 11 Jan 2016 10:47:58 +0100 (CET)
From: ordinatous@grp3.info-msj.net
blableblibloblu
Émetteur:X-Original-To ordinatous@grp3.info-msj.net
Recepteur:Delivred-To ordinatous@grp3.grp3.info-msj.net
Depuis la machine : from srv-debian.grp3.info-msj.net
Ainsi que le nom du serveur : mail.grp3.info-msj.net indiquant
de la résolution de nom s'effectue sans problème, la version du
serveur de mail : postfix.
De plus on voit clairement la date et l'heure, donc tout
fonctionne correctement.
contact@ordinatous.com 10/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
c) Connexion active
Vérifions les connexions actives avec :
netstat -anp
netstat -anp
Connexions Internet actives (serveurs et établies)
Proto Recv-Q Send-Q Adresse locale Adresse distante Etat
PID/Program name
tcp 0 0 0.0.0.0:34084 0.0.0.0:* LISTEN
402/rpc.statd
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN
3981/dovecot
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN
3981/dovecot
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
393/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
417/sshd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
847/master
tcp 0 0 172.25.3.34:22 172.25.3.31:52747 ESTABLISHED
579/sshd: ordinatou
tcp 0 0 172.25.3.34:22 172.25.3.21:60067 ESTABLISHED
639/sshd: ordinatou
tcp 0 0 172.25.3.34:22 172.25.3.21:60447 ESTABLISHED
4022/sshd: ordinato
tcp6 0 0 :::110 :::* LISTEN
3981/dovecot
tcp6 0 0 :::143 :::* LISTEN
3981/dovecot
tcp6 0 0 :::35951 :::* LISTEN
402/rpc.statd
tcp6 0 0 :::111 :::* LISTEN
393/rpcbind
tcp6 0 0 :::22 :::* LISTEN
417/sshd
tcp6 0 0 :::25 :::* LISTEN
847/master
tcp6 0 0 ::1:45839 ::1:25 ESTABLISHED
4037/telnet
tcp6 0 0 ::1:25 ::1:45839 ESTABLISHED
4038/smtpd
udp 0 0 0.0.0.0:992 0.0.0.0:*
393/rpcbind
udp 0 0 127.0.0.1:1002 0.0.0.0:*
402/rpc.statd
udp 0 0 0.0.0.0:111 0.0.0.0:*
393/rpcbind
udp 0 0 0.0.0.0:52015 0.0.0.0:*
402/rpc.statd
udp6 0 0 :::992 :::*
393/rpcbind
udp6 0 0 :::48123 :::*
402/rpc.statd
udp6 0 0 :::111 :::*
393/rpcbind
contact@ordinatous.com 11/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
d) Anti-spam/anti-virus
# apt-get install amavisd-new spamassassin clamav-daemon
use strict;
contact@ordinatous.com 12/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
e) Test
amavis
Contrôle du status avec systemctl.
Spamassassin
On modifie maintenant :
/etc/default/spamassassin
Et passons la valeur ENABLED=0 à 1
contact@ordinatous.com 13/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
f) Client « lourd »
Nous allons maintenant vérifier le fonctionnement avec
Thunderbird, j'ai une version libre de Thunderbird installé
sur ma machine répondant au nom de Icedove, que je vais
donc configurer.
Ajouter et configurer un compte :
contact@ordinatous.com 14/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
Configuration du compte
Il faut décocher gandi.net (nous ne sommes pas gandi.net),
comme nous avons une adresse mail nous pouvons :
passer cette étape et utiliser mon adresse existante
contact@ordinatous.com 15/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
contact@ordinatous.com 16/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
g) Squirrelmail
Squirrelmail est un client webmail, très léger donc ; on
récupère squirrelmail avec :
sudo apt-get install squirrelmail
Copier les fichiers de configuration apache de squirrelmai
dans le dossier apache2 des sites valable :
cp /etc/squirrelmail/apache.conf /etc/apache2/sites-
available/squirrelmail.conf
cd /etc/apache2/sites-available/
a2ensite squirrelmail
Modifions :
/usr/sbin/squirrelmail-configure
contact@ordinatous.com 17/22
Ludovic MARCHAL Formation : TSGERI Session 2015/2016
Et tout fonctionne .
contact@ordinatous.com 18/22