Logo

Installation d'un Serveur Mail Complet avec Postfix et Dovecot

Installation d'un Serveur Mail Complet avec Postfix et Dovecot

Guide complet pour configurer un serveur de messagerie professionnel sous Linux

Table des matiรจres

  1. Introduction et Architecture
  2. Prรฉrequis
  3. Installation des paquets
  4. Configuration DNS
  5. Configuration de Postfix
  6. Configuration de Dovecot
  7. Sรฉcurisation avec SSL/TLS
  8. Authentification SASL
  9. Tests et Validation
  10. Dรฉpannage

Introduction et Architecture

Qu'est-ce qu'un serveur mail ?

Un serveur mail gรจre l'envoi et la rรฉception des emails. Notre configuration utilise deux composants principaux :

  • Postfix : Agent de transfert de mail (MTA) - gรจre l'envoi et la rรฉception SMTP
  • Dovecot : Serveur IMAP/POP3 - permet aux clients de consulter leurs emails

Schรฉma d'Architecture Globale

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        ARCHITECTURE SERVEUR MAIL                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

    INTERNET                        SERVEUR                         CLIENTS
    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                        โ”€โ”€โ”€โ”€โ”€โ”€โ”€                         โ”€โ”€โ”€โ”€โ”€โ”€โ”€

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Serveur    โ”‚    Port 25     โ”‚                             โ”‚
โ”‚   Externe    โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚         POSTFIX             โ”‚
โ”‚   (SMTP)     โ”‚                โ”‚      (MTA - SMTP)           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                โ”‚                             โ”‚
                                โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
                                โ”‚   โ”‚    File d'attente   โ”‚   โ”‚
                                โ”‚   โ”‚    (Mail Queue)     โ”‚   โ”‚
                                โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
                                โ”‚              โ”‚              โ”‚
                                โ”‚              โ–ผ              โ”‚
                                โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
                                โ”‚   โ”‚     Maildir         โ”‚   โ”‚
                                โ”‚   โ”‚  /var/mail/vhosts/  โ”‚   โ”‚
                                โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
                                โ”‚              โ”‚              โ”‚
                                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                               โ”‚
                                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                โ”‚              โ–ผ              โ”‚
                                โ”‚         DOVECOT             โ”‚     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                โ”‚     (IMAP/POP3 Server)      โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚ Outlook  โ”‚
                                โ”‚                             โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ”‚   Ports: 993 (IMAPS)        โ”‚     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                โ”‚          995 (POP3S)        โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚Thunderbirdโ”‚
                                โ”‚          587 (Submission)   โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                                                    โ”‚ Webmail  โ”‚
                                                                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Flux de Communication

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         FLUX EMAIL ENTRANT                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ Envoyeurโ”‚     โ”‚   DNS   โ”‚     โ”‚ Postfix โ”‚     โ”‚ Dovecot โ”‚     โ”‚ Client  โ”‚
  โ”‚ Externe โ”‚     โ”‚  (MX)   โ”‚     โ”‚  (MTA)  โ”‚     โ”‚ (IMAP)  โ”‚     โ”‚  Mail   โ”‚
  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚  Requรชte MX   โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚  Rรฉponse MX   โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚          Connexion SMTP (port 25)             โ”‚               โ”‚
       โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚  Stockage     โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚  Maildir      โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚  Connexion    โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚  IMAP (993)   โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚  Emails       โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         FLUX EMAIL SORTANT                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ Client  โ”‚     โ”‚ Dovecot โ”‚     โ”‚ Postfix โ”‚     โ”‚   DNS   โ”‚     โ”‚Serveur  โ”‚
  โ”‚  Mail   โ”‚     โ”‚ (Auth)  โ”‚     โ”‚  (MTA)  โ”‚     โ”‚         โ”‚     โ”‚Distant  โ”‚
  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚  SMTP Auth    โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚  (port 587)   โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚  Validation   โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚  Requรชte MX   โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚  Rรฉponse MX   โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚  Envoi SMTP   โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚

Prรฉrequis

Configuration Systรจme Requise

ร‰lรฉmentMinimumRecommandรฉ
RAM512 Mo2 Go
Stockage10 Go50 Go+
OSUbuntu 20.04+ / Debian 11+Ubuntu 22.04 LTS
RรฉseauIP publique fixeIP dรฉdiรฉe

Ports ร  Ouvrir

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    PORTS Rร‰SEAU REQUIS                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Port  โ”‚   Protocole  โ”‚            Description                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   25   โ”‚   SMTP       โ”‚  Rรฉception emails (serveur ร  serveur)   โ”‚
โ”‚  587   โ”‚   Submission โ”‚  Envoi emails (client authentifiรฉ)      โ”‚
โ”‚  465   โ”‚   SMTPS      โ”‚  SMTP over SSL (legacy)                 โ”‚
โ”‚  993   โ”‚   IMAPS      โ”‚  IMAP over SSL (consultation emails)    โ”‚
โ”‚  995   โ”‚   POP3S      โ”‚  POP3 over SSL (tรฉlรฉchargement emails)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Vรฉrifications Prรฉalables

# Vรฉrifier le hostname
hostname -f

# Vรฉrifier que le port 25 n'est pas bloquรฉ
telnet smtp.google.com 25

# Vรฉrifier l'IP publique
curl ifconfig.me

Installation des Paquets

Ubuntu/Debian

# Mise ร  jour du systรจme
sudo apt update && sudo apt upgrade -y

# Installation de Postfix
sudo apt install postfix postfix-policyd-spf-python -y

# Lors de l'installation, choisir :
# - Type de configuration : Site Internet
# - Nom de courrier : votre-domaine.com

# Installation de Dovecot
sudo apt install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd -y

# Outils supplรฉmentaires
sudo apt install certbot mailutils -y

CentOS/RHEL

# Installation des dรฉpรดts EPEL
sudo dnf install epel-release -y

# Installation de Postfix
sudo dnf install postfix -y

# Installation de Dovecot
sudo dnf install dovecot dovecot-pigeonhole -y

# Activer les services
sudo systemctl enable postfix dovecot

Configuration DNS

Enregistrements DNS Requis

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    CONFIGURATION DNS REQUISE                                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  TYPE  โ”‚        NOM         โ”‚           VALEUR              โ”‚    TTL       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   A    โ”‚  mail              โ”‚  203.0.113.10                 โ”‚    3600      โ”‚
โ”‚   MX   โ”‚  @                 โ”‚  10 mail.votre-domaine.com    โ”‚    3600      โ”‚
โ”‚  TXT   โ”‚  @                 โ”‚  v=spf1 mx a -all             โ”‚    3600      โ”‚
โ”‚  TXT   โ”‚  _dmarc            โ”‚  v=DMARC1; p=quarantine       โ”‚    3600      โ”‚
โ”‚  PTR   โ”‚  10.113.0.203      โ”‚  mail.votre-domaine.com       โ”‚    3600      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Lรฉgende :
  โ€ข A    : Pointe le sous-domaine "mail" vers l'IP du serveur
  โ€ข MX   : Indique le serveur mail pour le domaine
  โ€ข TXT  : SPF pour l'authentification des emails sortants
  โ€ข TXT  : DMARC pour la politique de traitement des emails
  โ€ข PTR  : Reverse DNS (ร  configurer chez l'hรฉbergeur)

Vรฉrification DNS

# Vรฉrifier l'enregistrement MX
dig MX votre-domaine.com +short

# Vรฉrifier l'enregistrement A
dig A mail.votre-domaine.com +short

# Vรฉrifier le SPF
dig TXT votre-domaine.com +short

# Vรฉrifier le reverse DNS
dig -x VOTRE_IP_PUBLIQUE +short

Configuration de Postfix

Architecture Interne de Postfix

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    ARCHITECTURE INTERNE POSTFIX                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                              โ”‚    smtpd         โ”‚โ—€โ”€โ”€โ”€ Port 25 (entrant)
                              โ”‚  (rรฉception)     โ”‚โ—€โ”€โ”€โ”€ Port 587 (submission)
                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                       โ”‚
                                       โ–ผ
                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                              โ”‚    cleanup       โ”‚
                              โ”‚  (vรฉrification)  โ”‚
                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                       โ”‚
                                       โ–ผ
                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                              โ”‚     qmgr         โ”‚
                              โ”‚ (gestionnaire    โ”‚
                              โ”‚   de queue)      โ”‚
                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                       โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚                        โ”‚                        โ”‚
              โ–ผ                        โ–ผ                        โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚    smtp      โ”‚         โ”‚    lmtp      โ”‚         โ”‚   local      โ”‚
     โ”‚  (sortant)   โ”‚         โ”‚  (Dovecot)   โ”‚         โ”‚ (systรจme)    โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
              โ”‚                        โ”‚                        โ”‚
              โ–ผ                        โ–ผ                        โ–ผ
     Serveurs externes         Dovecot LMTP              /var/mail/

Fichier /etc/postfix/main.cf

# Crรฉer une sauvegarde
sudo cp /etc/postfix/main.cf /etc/postfix/main.cf.backup

# ร‰diter le fichier principal
sudo nano /etc/postfix/main.cf
# =============================================================================
# POSTFIX - CONFIGURATION PRINCIPALE
# =============================================================================

# -----------------------------------------------------------------------------
# IDENTITร‰ DU SERVEUR
# -----------------------------------------------------------------------------
myhostname = mail.votre-domaine.com
mydomain = votre-domaine.com
myorigin = $mydomain

# -----------------------------------------------------------------------------
# Rร‰SEAUX ET INTERFACES
# -----------------------------------------------------------------------------
inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

# -----------------------------------------------------------------------------
# BOรŽTES AUX LETTRES
# -----------------------------------------------------------------------------
home_mailbox = Maildir/
mailbox_size_limit = 0
recipient_delimiter = +

# -----------------------------------------------------------------------------
# TLS/SSL
# -----------------------------------------------------------------------------
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.votre-domaine.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.votre-domaine.com/privkey.pem
smtpd_tls_security_level = may
smtpd_tls_auth_only = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s

smtp_tls_security_level = may
smtp_tls_loglevel = 1

# Protocoles et ciphers sรฉcurisรฉs
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1

# -----------------------------------------------------------------------------
# AUTHENTIFICATION SASL (via Dovecot)
# -----------------------------------------------------------------------------
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = yes

# -----------------------------------------------------------------------------
# RESTRICTIONS
# -----------------------------------------------------------------------------
smtpd_helo_required = yes
smtpd_helo_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_invalid_helo_hostname,
    reject_non_fqdn_helo_hostname

smtpd_sender_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_non_fqdn_sender,
    reject_unknown_sender_domain

smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination,
    reject_non_fqdn_recipient,
    reject_unknown_recipient_domain

# -----------------------------------------------------------------------------
# LIMITES ET PERFORMANCES
# -----------------------------------------------------------------------------
message_size_limit = 52428800
mailbox_size_limit = 0
smtpd_client_connection_count_limit = 10
smtpd_client_connection_rate_limit = 30

Fichier /etc/postfix/master.cf

sudo nano /etc/postfix/master.cf
# =============================================================================
# POSTFIX - SERVICES
# =============================================================================

# Service SMTP standard (port 25)
smtp      inet  n       -       y       -       -       smtpd

# Submission (port 587) - pour les clients authentifiรฉs
submission inet n       -       y       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_tls_auth_only=yes
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

# SMTPS (port 465) - SMTP over SSL
smtps     inet  n       -       y       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

Configuration de Dovecot

Architecture Interne de Dovecot

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    ARCHITECTURE INTERNE DOVECOT                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

   Clients Mail                    Dovecot                      Stockage
   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                     โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Outlook   โ”‚โ”€โ”€โ”
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚         โ”‚                             โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚  IMAPS  โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚Thunderbird โ”‚โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚   โ”‚    imap-login       โ”‚   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚  (993)  โ”‚   โ”‚    (authentif.)     โ”‚   โ”‚
                โ”‚         โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚         โ”‚              โ”‚              โ”‚
โ”‚   Mobile   โ”‚โ”€โ”€โ”˜         โ”‚              โ–ผ              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                          โ”‚   โ”‚    imap             โ”‚   โ”‚     โ”‚               โ”‚
                          โ”‚   โ”‚    (protocole)      โ”‚   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Maildir     โ”‚
                          โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚     โ”‚               โ”‚
                          โ”‚                             โ”‚     โ”‚ /var/mail/    โ”‚
                          โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚     โ”‚   vhosts/     โ”‚
                          โ”‚   โ”‚    auth             โ”‚โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ–ถโ”‚   domain/     โ”‚
                          โ”‚   โ”‚    (SASL)           โ”‚   โ”‚     โ”‚     user/     โ”‚
                          โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚     โ”‚               โ”‚
                          โ”‚              โ”‚              โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚              โ–ผ              โ”‚
                          โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
       Postfix โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚   โ”‚    auth-userdb      โ”‚   โ”‚
       (SASL)             โ”‚   โ”‚    (socket)         โ”‚   โ”‚
                          โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
                          โ”‚                             โ”‚
                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Fichier /etc/dovecot/dovecot.conf

sudo nano /etc/dovecot/dovecot.conf
# =============================================================================
# DOVECOT - CONFIGURATION PRINCIPALE
# =============================================================================

# Protocoles activรฉs
protocols = imap pop3 lmtp

# ร‰couter sur toutes les interfaces
listen = *, ::

# Inclure les configurations modulaires
!include conf.d/*.conf

Fichier /etc/dovecot/conf.d/10-mail.conf

sudo nano /etc/dovecot/conf.d/10-mail.conf
# =============================================================================
# DOVECOT - CONFIGURATION STOCKAGE MAIL
# =============================================================================

# Emplacement des boรฎtes mail (format Maildir)
mail_location = maildir:~/Maildir

# Namespace pour la boรฎte de rรฉception
namespace inbox {
  inbox = yes
}

# Utilisateur/groupe pour accรฉder aux mails
mail_uid = vmail
mail_gid = vmail

# Privilรจges
mail_privileged_group = mail

# Premiรจre UID/GID valide
first_valid_uid = 1000
first_valid_gid = 1000

Fichier /etc/dovecot/conf.d/10-auth.conf

sudo nano /etc/dovecot/conf.d/10-auth.conf
# =============================================================================
# DOVECOT - AUTHENTIFICATION
# =============================================================================

# Dรฉsactiver l'authentification en clair sans SSL
disable_plaintext_auth = yes

# Mรฉcanismes d'authentification
auth_mechanisms = plain login

# Inclure la configuration systรจme
!include auth-system.conf.ext

Fichier /etc/dovecot/conf.d/10-ssl.conf

sudo nano /etc/dovecot/conf.d/10-ssl.conf
# =============================================================================
# DOVECOT - CONFIGURATION SSL/TLS
# =============================================================================

# Activer SSL
ssl = required

# Certificats Let's Encrypt
ssl_cert = </etc/letsencrypt/live/mail.votre-domaine.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.votre-domaine.com/privkey.pem

# Protocoles autorisรฉs (dรฉsactiver les anciens)
ssl_min_protocol = TLSv1.2

# Prรฉfรฉrer les ciphers du serveur
ssl_prefer_server_ciphers = yes

# Ciphers sรฉcurisรฉs
ssl_cipher_list = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384

Fichier /etc/dovecot/conf.d/10-master.conf

sudo nano /etc/dovecot/conf.d/10-master.conf
# =============================================================================
# DOVECOT - SERVICES ET SOCKETS
# =============================================================================

service imap-login {
  inet_listener imap {
    port = 0  # Dรฉsactivรฉ (non sรฉcurisรฉ)
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}

service pop3-login {
  inet_listener pop3 {
    port = 0  # Dรฉsactivรฉ (non sรฉcurisรฉ)
  }
  inet_listener pop3s {
    port = 995
    ssl = yes
  }
}

service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    mode = 0600
    user = postfix
    group = postfix
  }
}

# Socket d'authentification pour Postfix
service auth {
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
  
  unix_listener auth-userdb {
    mode = 0600
    user = vmail
  }
  
  user = dovecot
}

service auth-worker {
  user = vmail
}

Sรฉcurisation avec SSL/TLS

Obtenir un Certificat Let's Encrypt

# Arrรชter temporairement les services
sudo systemctl stop postfix dovecot

# Obtenir le certificat
sudo certbot certonly --standalone -d mail.votre-domaine.com

# Redรฉmarrer les services
sudo systemctl start postfix dovecot

Renouvellement Automatique

# Crรฉer un script de renouvellement
sudo nano /etc/letsencrypt/renewal-hooks/post/mail-services.sh
#!/bin/bash
systemctl reload postfix
systemctl reload dovecot
# Rendre exรฉcutable
sudo chmod +x /etc/letsencrypt/renewal-hooks/post/mail-services.sh

# Tester le renouvellement
sudo certbot renew --dry-run

Authentification SASL

Schรฉma d'Authentification

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    FLUX D'AUTHENTIFICATION SASL                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ Client  โ”‚     โ”‚ Postfix โ”‚     โ”‚ Socket  โ”‚     โ”‚ Dovecot โ”‚     โ”‚  PAM/   โ”‚
  โ”‚  Mail   โ”‚     โ”‚  SMTP   โ”‚     โ”‚  Auth   โ”‚     โ”‚  Auth   โ”‚     โ”‚ Passwd  โ”‚
  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚  EHLO         โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚  250-AUTH     โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚  AUTH LOGIN   โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚  user:pass    โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚  Verify      โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚  Check       โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚  Validate    โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚  OK/FAIL     โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚  Result      โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚  Result      โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚  235 Auth OK  โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚               โ”‚               โ”‚               โ”‚
       โ”‚               โ”‚               โ”‚               โ”‚               โ”‚

Crรฉation d'un Utilisateur Mail

# Crรฉer le groupe vmail
sudo groupadd -g 5000 vmail

# Crรฉer l'utilisateur vmail
sudo useradd -g vmail -u 5000 vmail -d /var/mail

# Crรฉer le rรฉpertoire de stockage
sudo mkdir -p /var/mail/vhosts/votre-domaine.com

# Dรฉfinir les permissions
sudo chown -R vmail:vmail /var/mail/vhosts

# Crรฉer un utilisateur systรจme pour le mail
sudo useradd -m -s /bin/bash utilisateur1
sudo passwd utilisateur1

# Crรฉer la structure Maildir
sudo -u utilisateur1 mkdir -p /home/utilisateur1/Maildir/{cur,new,tmp}

Tests et Validation

Script de Test Complet

#!/bin/bash
# test-mail-server.sh

echo "=== Test du Serveur Mail ==="

# Test 1: Vรฉrifier que Postfix รฉcoute
echo -n "Port 25 (SMTP): "
nc -zv localhost 25 2>&1 | grep -q "succeeded" && echo "OK" || echo "ERREUR"

echo -n "Port 587 (Submission): "
nc -zv localhost 587 2>&1 | grep -q "succeeded" && echo "OK" || echo "ERREUR"

# Test 2: Vรฉrifier que Dovecot รฉcoute
echo -n "Port 993 (IMAPS): "
nc -zv localhost 993 2>&1 | grep -q "succeeded" && echo "OK" || echo "ERREUR"

echo -n "Port 995 (POP3S): "
nc -zv localhost 995 2>&1 | grep -q "succeeded" && echo "OK" || echo "ERREUR"

# Test 3: Vรฉrifier le certificat SSL
echo -n "Certificat SSL: "
openssl s_client -connect localhost:993 -servername mail.votre-domaine.com </dev/null 2>/dev/null | grep -q "Verify return code: 0" && echo "OK" || echo "Vร‰RIFIER"

# Test 4: Vรฉrifier la configuration Postfix
echo -n "Configuration Postfix: "
postfix check 2>&1 | grep -q "error" && echo "ERREUR" || echo "OK"

# Test 5: Vรฉrifier la configuration Dovecot
echo -n "Configuration Dovecot: "
dovecot -n 2>&1 | grep -q "Error" && echo "ERREUR" || echo "OK"

echo "=== Fin des Tests ==="

Envoyer un Email de Test

# Via la ligne de commande
echo "Ceci est un test" | mail -s "Test Email" [email protected]

# Vรฉrifier les logs
sudo tail -f /var/log/mail.log

Test avec Telnet/OpenSSL

# Test SMTP
openssl s_client -connect mail.votre-domaine.com:587 -starttls smtp

# Test IMAP
openssl s_client -connect mail.votre-domaine.com:993

Dรฉpannage

Commandes de Diagnostic

# Vรฉrifier l'รฉtat des services
sudo systemctl status postfix
sudo systemctl status dovecot

# Consulter les logs en temps rรฉel
sudo tail -f /var/log/mail.log
sudo tail -f /var/log/mail.err

# Vรฉrifier la queue Postfix
sudo postqueue -p

# Forcer l'envoi de la queue
sudo postqueue -f

# Supprimer tous les messages en queue
sudo postsuper -d ALL

# Tester la configuration Postfix
sudo postfix check

# Tester la configuration Dovecot
sudo doveconf -n

Problรจmes Frรฉquents

ProblรจmeCause ProbableSolution
Connection refused port 25Postfix non dรฉmarrรฉ ou port bloquรฉsystemctl start postfix / Vรฉrifier firewall
SSL handshake failedCertificat invalide ou expirรฉRenouveler avec certbot renew
Authentication failedMauvais mot de passe ou config SASLVรฉrifier /var/log/auth.log
Emails rejetรฉsSPF/DKIM/DMARC mal configurรฉsVรฉrifier les enregistrements DNS
Maildir non crรฉรฉPermissions incorrecteschown -R vmail:vmail /var/mail

Schรฉma de Rรฉsolution

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    ARBRE DE Dร‰CISION - Dร‰PANNAGE                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

                           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                           โ”‚ Email ne part   โ”‚
                           โ”‚   pas ?         โ”‚
                           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ–ผ                               โ–ผ
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ”‚ Service actif โ”‚               โ”‚ Service arrรชtรฉโ”‚
           โ”‚    ?          โ”‚               โ”‚               โ”‚
           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚                               โ”‚
                   โ–ผ                               โ–ผ
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚ Vรฉrifier les     โ”‚            โ”‚ systemctl start  โ”‚
        โ”‚ logs mail.log    โ”‚            โ”‚ postfix          โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ–ผ            โ–ผ            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Auth   โ”‚  โ”‚ DNS    โ”‚  โ”‚ Quota  โ”‚
โ”‚ Error  โ”‚  โ”‚ Error  โ”‚  โ”‚ Error  โ”‚
โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
    โ”‚           โ”‚           โ”‚
    โ–ผ           โ–ผ           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚Vรฉrifierโ”‚  โ”‚Vรฉrifierโ”‚  โ”‚Vรฉrifierโ”‚
โ”‚passwordโ”‚  โ”‚MX, SPF โ”‚  โ”‚espace  โ”‚
โ”‚& SASL  โ”‚  โ”‚DMARC   โ”‚  โ”‚disque  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Rรฉcapitulatif des Fichiers

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    STRUCTURE DES FICHIERS DE CONFIGURATION                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

/etc/
โ”œโ”€โ”€ postfix/
โ”‚   โ”œโ”€โ”€ main.cf              โ† Configuration principale Postfix
โ”‚   โ”œโ”€โ”€ master.cf            โ† Services et ports
โ”‚   โ””โ”€โ”€ main.cf.backup       โ† Sauvegarde
โ”‚
โ”œโ”€โ”€ dovecot/
โ”‚   โ”œโ”€โ”€ dovecot.conf         โ† Configuration principale Dovecot
โ”‚   โ””โ”€โ”€ conf.d/
โ”‚       โ”œโ”€โ”€ 10-mail.conf     โ† Stockage des mails
โ”‚       โ”œโ”€โ”€ 10-auth.conf     โ† Authentification
โ”‚       โ”œโ”€โ”€ 10-ssl.conf      โ† Certificats SSL
โ”‚       โ””โ”€โ”€ 10-master.conf   โ† Services et sockets
โ”‚
โ””โ”€โ”€ letsencrypt/
    โ””โ”€โ”€ live/
        โ””โ”€โ”€ mail.votre-domaine.com/
            โ”œโ”€โ”€ fullchain.pem    โ† Certificat + chaรฎne
            โ””โ”€โ”€ privkey.pem      โ† Clรฉ privรฉe

/var/
โ”œโ”€โ”€ mail/
โ”‚   โ””โ”€โ”€ vhosts/
โ”‚       โ””โ”€โ”€ votre-domaine.com/   โ† Boรฎtes mail (Maildir)
โ”‚
โ””โ”€โ”€ log/
    โ”œโ”€โ”€ mail.log             โ† Logs principaux
    โ””โ”€โ”€ mail.err             โ† Erreurs

Annexes

A. Commandes Utiles

# Gestion des services
sudo systemctl {start|stop|restart|status} postfix
sudo systemctl {start|stop|restart|status} dovecot

# Logs
sudo journalctl -u postfix -f
sudo journalctl -u dovecot -f

# Queue
sudo postqueue -p          # Afficher la queue
sudo postsuper -d ALL      # Vider la queue

# Utilisateurs
sudo doveadm user '*'      # Lister les utilisateurs

B. Checklist de Dรฉploiement

  • DNS : Enregistrements A, MX, SPF, DMARC configurรฉs
  • Reverse DNS (PTR) configurรฉ
  • Certificat SSL obtenu et valide
  • Postfix configurรฉ et testรฉ
  • Dovecot configurรฉ et testรฉ
  • Authentification SASL fonctionnelle
  • Firewall : Ports 25, 587, 993, 995 ouverts
  • Test d'envoi et rรฉception rรฉussi
  • Renouvellement automatique du certificat configurรฉ

Rejoignez notre serveur communautaire Discord

Pour toute question, suggestion ou simplement pour discuter avec la communautรฉ, rejoignez-nous sur Discord !

900+Membres