Info:: apsi.net: DOCUMENTATION MAIL SERVER
KEYWORDS: MAIL, SERVER, APSI.NET, OVH1, MAIL.APSI.NET, OVH2, BACKUP.APSI.NET
Le 04/01/2026:
Documentation Serveur Mail APSI.NET
Infrastructure Mail avec Relay Backup
Date de création : 31 Décembre 2025 Domaines gérés : apsi.net, voilou.nl
Architecture Globale
Serveurs
ovh1.pcstreet.org (mail.apsi.net)
- IP : 51.83.2.131
- Rôle : Serveur mail principal (MX 10)
- Services : Postfix, Dovecot, Roundcube, Apache
- Certificats : Let’s Encrypt (mail.apsi.net)
ovh2.pcstreet.org (backup.apsi.net)
- IP : 51.68.207.177
- Rôle : Relay backup (MX 20)
- Services : Postfix relay uniquement
- Fonction : Met les emails en queue si ovh1 est indisponible
Comptes Email
- pchevalier@apsi.net (mot de passe: 11as95ap23)
- pchevalier@voilou.nl (mot de passe: 11as95ap23)
- contact@apsi.net (mot de passe: 11as95ap23)
- contact@voilou.nl (mot de passe: 11as95ap23)
Configuration DNS
Enregistrements MX
apsi.net. MX 10 mail.apsi.net apsi.net. MX 20 backup.apsi.net voilou.nl MX 10 mail.apsi.net voilou.nl MX 20 backup.apsi.net
Enregistrements A
mail.apsi.net A 51.83.2.131 backup.apsi.net A 51.68.207.177
Configuration OVH1 (Serveur Principal)
Postfix - /etc/postfix/main.cf
Certificats TLS :
smtpd_tls_cert_file=/etc/letsencrypt/live/mail.apsi.net/fullchain.pem smtpd_tls_key_file=/etc/letsencrypt/live/mail.apsi.net/privkey.pem smtpd_tls_security_level=may
Authentication SASL (Dovecot) :
smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous
Hostname et domaines :
myhostname = mail.apsi.net mydestination = $myhostname, apsi.net, voilou.nl, localhost home_mailbox = Maildir/
Restrictions :
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
Dovecot - /etc/dovecot/conf.d/
10-mail.conf :
mail_location = maildir:~/Maildir
10-ssl.conf :
ssl_cert = </etc/letsencrypt/live/mail.apsi.net/fullchain.pem ssl_key = </etc/letsencrypt/live/mail.apsi.net/privkey.pem
10-master.conf (Auth socket pour Postfix) :
service auth {
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
}
Roundcube - /etc/roundcube/config.inc.php
Connexion IMAP :
$config['default_host'] = 'tls://localhost';
$config['default_port'] = 143;
$config['imap_auth_type'] = null; // Auto-detect
$config['imap_conn_options'] = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
),
);
Connexion SMTP :
$config['smtp_server'] = 'tls://localhost';
$config['smtp_port'] = 587;
$config['smtp_user'] = '%u';
$config['smtp_pass'] = '%p';
$config['smtp_auth_type'] = null;
Permissions fichier :
chown root:www-data /etc/roundcube/config.inc.php
chmod 640 /etc/roundcube/config.inc.php
Firewall - /etc/iptables.d.new/iptables.start
Ports ouverts :
# Port 25 : SMTP (réception depuis autres serveurs mail)
# Port 587 : Submission avec STARTTLS
# Port 465 : SMTPS (envoi authentifié SSL/TLS)
# Port 143 : IMAP (lecture emails)
# Port 993 : IMAPS (lecture emails sécurisée SSL/TLS)
iptables -A INPUT -p tcp -m multiport --dports 25,587,465,143,993 -j ACCEPT
Fail2ban
Jails actifs : - postfix-sasl (protection auth SMTP) - dovecot (protection auth IMAP) - sshd
Configuration OVH2 (Relay Backup)
Postfix - /etc/postfix/main.cf
Configuration relay :
myhostname = backup.apsi.net relay_domains = apsi.net, voilou.nl relay_transport = smtp:[mail.apsi.net]:25 inet_protocols = ipv4 mailbox_size_limit = 0 message_size_limit = 52428800
Résolution DNS - /etc/hosts
Ajout pour résolution directe :
51.83.2.131 mail.apsi.net
Firewall - /etc/iptables.d.new/iptables.start.ClaudePayant
Ports ouverts :
# Port 25 : SMTP pour relay de backup mail
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
ip6tables -A INPUT -p tcp --dport 25 -j ACCEPT
# SORTIES MAIL : permettre au serveur relay d'envoyer vers ovh1
iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 25 -j ACCEPT
Configuration SPF, DKIM et DMARC
OpenDKIM - /etc/opendkim.conf
Configuration multi-domaines :
Mode sv Canonicalization relaxed/simple Socket local:/var/spool/postfix/opendkim/opendkim.sock KeyTable refile:/etc/opendkim/KeyTable SigningTable refile:/etc/opendkim/SigningTable ExternalIgnoreList /etc/opendkim/TrustedHosts InternalHosts /etc/opendkim/TrustedHosts
Fichiers de configuration :
/etc/opendkim/KeyTable :
mail._domainkey.apsi.net apsi.net:mail:/etc/opendkim/keys/apsi.net/mail.private mail._domainkey.voilou.nl voilou.nl:mail:/etc/opendkim/keys/voilou.nl/mail.private
/etc/opendkim/SigningTable :
*@apsi.net mail._domainkey.apsi.net *@voilou.nl mail._domainkey.voilou.nl
/etc/opendkim/TrustedHosts :
127.0.0.1 localhost mail.apsi.net apsi.net voilou.nl 51.83.2.131
Postfix Integration - /etc/postfix/main.cf
Configuration milter :
milter_default_action = accept milter_protocol = 6 smtpd_milters = local:opendkim/opendkim.sock non_smtpd_milters = $smtpd_milters
Clés DKIM Générées
Emplacement : - /etc/opendkim/keys/apsi.net/mail.private (clé privée) - /etc/opendkim/keys/voilou.nl/mail.private (clé privée)
Taille des clés : 1024 bits (compatibles PowerAdmin) - Les clés ont été générées en 1024 bits car PowerAdmin tronque les enregistrements TXT longs - Les clés 2048 bits (~400 caractères) dépassent la limite de PowerAdmin - Les clés 1024 bits (~230 caractères) fonctionnent correctement
Permissions :
chown opendkim:opendkim /etc/opendkim/keys/*/mail.private
chmod 600 /etc/opendkim/keys/*/mail.private
Enregistrements DNS à Ajouter
Fichier complet : /root/IA/MAIL.APSI.NET/DNS_RECORDS_SPF_DKIM_DMARC.txt
Pour apsi.net :
SPF (TXT) :
apsi.net. TXT "v=spf1 mx ip4:51.83.2.131 ip4:51.68.207.177 ~all"
DKIM (TXT) - Clé 1024 bits compatible PowerAdmin :
mail._domainkey.apsi.net. TXT "v=DKIM1; h=sha256; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDoDc7b7mrS9IEkE331OW/1wYAoCWfaSoU9orNrEm7zclCCYh62hjYJMbQT5rVcISH/hU3uOTUyGjUwqFw/emYw3CnwJwwOSgqM44n30cBwWP3+piy+DnPXFZpJDR4iBBYTygbKXu3X0BCAgX7pnD79kqLxaRjktn3sBYa/RP9ZZQIDAQAB"
DMARC (TXT) :
_dmarc.apsi.net. TXT "v=DMARC1; p=quarantine; rua=mailto:postmaster@apsi.net; ruf=mailto:postmaster@apsi.net; fo=1; adkim=r; aspf=r; pct=100"
Pour voilou.nl :
SPF (TXT) :
voilou.nl. TXT "v=spf1 mx ip4:51.83.2.131 ip4:51.68.207.177 ~all"
DKIM (TXT) - Clé 1024 bits compatible PowerAdmin :
mail._domainkey.voilou.nl. TXT "v=DKIM1; h=sha256; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMonQQKDHEUPkcQFr0Uxeaqpw0tF2pm/NiEIvPBM7TCmLZUJ9tu9yviBO9Mrrn2hDjdNSgAxWNWIzzRPIlpfCrRnUdqOOp+NeftiqsBP02pg8bQDQxgA+InGSgvQYhGd6BDF6yxA8lf7eNkVEDGrPfnNRLSJMWzJveTpzVIjIwfwIDAQAB"
DMARC (TXT) :
_dmarc.voilou.nl. TXT "v=DMARC1; p=quarantine; rua=mailto:postmaster@voilou.nl; ruf=mailto:postmaster@voilou.nl; fo=1; adkim=r; aspf=r; pct=100"
Vérification DNS
Après ajout des enregistrements (délai 1-24h) :
# Vérifier SPF
dig +short TXT apsi.net
dig +short TXT voilou.nl
# Vérifier DKIM
dig +short TXT mail._domainkey.apsi.net
dig +short TXT mail._domainkey.voilou.nl
# Vérifier DMARC
dig +short TXT _dmarc.apsi.net
dig +short TXT _dmarc.voilou.nl
Test de Signature DKIM
Vérifier qu’OpenDKIM signe les emails :
# Logs OpenDKIM
journalctl -u opendkim -n 50
# Tester les clés
opendkim-testkey -d apsi.net -s mail -vvv
opendkim-testkey -d voilou.nl -s mail -vvv
# Vérifier signature dans email
grep "DKIM-Signature" /home/pchevalier/Maildir/cur/*
Résultat attendu dans les logs :
opendkim: DKIM-Signature field added (s=mail, d=apsi.net)
Tests en Ligne
Envoyer un email de test à : - check-auth@verifier.port25.com - postmaster@dkimvalidator.com
Ces services renvoient un rapport complet sur SPF, DKIM et DMARC.
Configuration Client Thunderbird
Paramètres IMAP
- Serveur : mail.apsi.net
- Port : 143
- Sécurité : STARTTLS
- Auth : Mot de passe normal
- Nom utilisateur : pchevalier@apsi.net
Paramètres SMTP
- Serveur : mail.apsi.net
- Port : 587
- Sécurité : STARTTLS
- Auth : Mot de passe normal
- Nom utilisateur : pchevalier@apsi.net
IMPORTANT : Utiliser le hostname mail.apsi.net, pas l’adresse IP, pour éviter les erreurs de certificat.
Tests de Validation
Test 1 : Relay en Mode Normal
Commande :
ssh root@ovh2.pcstreet.org 'echo "Test relay" | sendmail pchevalier@apsi.net'
Résultat : - ✅ Connexion TLS 1.3 établie entre ovh2 et ovh1 - ✅ Email livré dans /home/pchevalier/Maildir/new/ - ✅ Logs montrent : status=sent (delivered to maildir)
Logs ovh1 :
postfix/smtpd: Anonymous TLS connection established from ovh2.pcstreet.org[51.68.207.177]: TLSv1.3 postfix/local: to=<pchevalier@apsi.net>, relay=local, dsn=2.0.0, status=sent (delivered to maildir)
Test 2 : Relay en Mode Panne
Étapes : 1. Arrêt de Postfix sur ovh1 : systemctl stop postfix 2. Envoi email depuis ovh2 3. Vérification queue ovh2 : mailq montre email en attente avec “Connection refused” 4. Redémarrage ovh1 : systemctl start postfix 5. Force flush queue ovh2 : postqueue -f 6. Vérification : queue vide, email livré
Résultat : - ✅ Email mis en queue pendant la panne - ✅ Email automatiquement livré après récupération - ✅ Aucune perte de mail
Accès Webmail
URL : https://apsi.net/roundcube/
Login : - Utilisateur : pchevalier@apsi.net - Mot de passe : 11as95ap23
Commandes Utiles
Surveillance des logs en temps réel
# Sur ovh1
tail -f /var/log/mail.log
# Sur ovh2
ssh root@ovh2.pcstreet.org 'tail -f /var/log/mail.log'
Vérifier la queue mail
# Sur ovh1
mailq
# Sur ovh2
ssh root@ovh2.pcstreet.org 'mailq'
Forcer le flush de la queue
postqueue -f
Tester IMAP manuellement
timeout 5 bash -c '
exec 3<>/dev/tcp/localhost/993
cat <&3 &
echo "a1 LOGIN pchevalier@apsi.net 11as95ap23" >&3
sleep 1
echo "a2 LOGOUT" >&3
sleep 1
'
Vérifier les certificats
openssl s_client -connect mail.apsi.net:993 -starttls imap
openssl s_client -connect mail.apsi.net:587 -starttls smtp
Statut des services
systemctl status postfix
systemctl status dovecot
systemctl status apache2
systemctl status fail2ban
Sécurité
Fail2ban Protection
- Bannissement après : 5 tentatives échouées
- Durée ban : 10 minutes
- Services protégés : Postfix SASL, Dovecot IMAP, SSH
Firewall
- Seuls les ports mail nécessaires sont ouverts
- Connexions sortantes mail autorisées pour relay
- Protection DDoS basique active
Certificats SSL/TLS
- Émetteur : Let’s Encrypt
- Renouvellement : Automatique via certbot
- Protocoles : TLS 1.2 minimum
- Ciphers : Strong ciphers uniquement
Maintenance
Renouvellement certificats Let’s Encrypt
certbot renew --dry-run # Test
certbot renew # Renouvellement réel
systemctl reload postfix dovecot apache2
Rotation des logs
Les logs sont automatiquement rotés par logrotate.
Mise à jour du système
apt update && apt upgrade
systemctl restart postfix dovecot apache2
Dépannage
Email non reçu
- Vérifier les logs :
tail -n 100 /var/log/mail.log - Vérifier la queue :
mailq - Vérifier le pare-feu :
iptables -L -n - Tester la connectivité :
telnet mail.apsi.net 25
Roundcube ne se connecte pas
- Vérifier permissions :
ls -l /etc/roundcube/config.inc.php - Vérifier logs :
tail /var/log/roundcube/*.log - Vérifier Dovecot :
systemctl status dovecot - Tester IMAP :
telnet localhost 143
Relay ne fonctionne pas
- Vérifier DNS :
host mail.apsi.net(sur ovh2) - Vérifier connectivité :
telnet mail.apsi.net 25(depuis ovh2) - Vérifier logs ovh2 :
tail -f /var/log/mail.log - Vérifier configuration relay :
postconf relay_domains relay_transport
Résumé Architecture
Internet | v [MX 10] mail.apsi.net (51.83.2.131) - ovh1 | +-- Postfix (SMTP: 25, 587, 465) +-- Dovecot (IMAP: 143, 993) +-- Roundcube (HTTPS: 443) +-- Fail2ban | v /home/*/Maildir/ [MX 20] backup.apsi.net (51.68.207.177) - ovh2 | +-- Postfix Relay +-- Queue backup si ovh1 down | v (relay vers) mail.apsi.net:25
Flux normal : Internet → ovh1 → Postfix → Dovecot → Maildir → Thunderbird/Roundcube
Flux si panne ovh1 : Internet → ovh2 → Queue → (attente récupération ovh1) → ovh1 → Maildir
Auteur
Configuration réalisée le 31 décembre 2025. Tests validés avec succès en mode normal et mode panne.