Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| linux:postfix [15-10-2025 21:15] – [Utiliser notre postfix comme un serveur relay via le port 587 avec authentification] edmc73 | linux:postfix [25-05-2026 13:07] (Version actuelle) – [1. Prérequis] edmc73 | ||
|---|---|---|---|
| Ligne 346: | Ligne 346: | ||
| ===== Recevoir des mails directement dans une petite interface web de consultation uniquement ===== | ===== Recevoir des mails directement dans une petite interface web de consultation uniquement ===== | ||
| - | Concrètement, | + | Objectif : Vous envoyez |
| + | ==== 1. Prérequis ==== | ||
| Installer **maildev** -> https:// | Installer **maildev** -> https:// | ||
| - | Je commence par ajouter | + | Ou plus optimisé, **Mailpit** via un container ou systemd |
| + | mailpit --smtp-bind 127.0.0.1: | ||
| + | ==== 2. Configuration DNS ==== | ||
| + | |||
| + | Ajoutez | ||
| toto.com IN MX 10 mon_serveur_smtp.com | toto.com IN MX 10 mon_serveur_smtp.com | ||
| - | J' | + | ==== 3. Configuration de Postfix ==== |
| - | noreply@toto.com smtp:localhost:1025 | + | |
| + | On va dire à Postfix de relayer les mails de ce domaine vers le port local de MailDev. \\ | ||
| + | Créez ou modifiez le fichier **/ | ||
| + | noreply@toto.com smtp:[127.0.0.1]:1025 | ||
| - | On hash le fichier | + | Hashez |
| postmap / | postmap / | ||
| - | On modifie le fichier | + | Ajoutez ou modifiez ces directives dans **/ |
| < | < | ||
| - | # prise en compte du fichier de transport | + | # Prise en compte du fichier de routage personnalisé |
| transport_maps = hash:/ | transport_maps = hash:/ | ||
| - | # on dit que si un mail vient de ce domaine, on ne cherche pas un user en local, on utilise le fichier de transport | + | # On indique à Postfix d' |
| relay_domains = toto.com | relay_domains = toto.com | ||
| </ | </ | ||
| - | On restart postfix | + | ==== 4. Application et Vérification ==== |
| + | Redémarrez Postfix pour appliquer les changements : | ||
| systemctl restart postfix | systemctl restart postfix | ||
| - | On consulte le journal | + | Inspectez les logs en temps réel pour valider les arrivées : |
| - | | + | |
| - | Et voila, on recevra directement dans maildev les mails adressés | + | Envoyez un mail à '' |
| ===== Utiliser notre postfix comme un serveur relay via le port 587 avec authentification ===== | ===== Utiliser notre postfix comme un serveur relay via le port 587 avec authentification ===== | ||
| - | Dans l' | + | Dans l' |
| + | |||
| + | Le port 587 est géré par le service " | ||
| + | |||
| + | < | ||
| + | submission inet n | ||
| + | -o syslog_name=postfix/ | ||
| + | -o smtpd_tls_security_level=encrypt | ||
| + | -o smtpd_sasl_auth_enable=yes | ||
| + | </ | ||
| Configuration dans **/ | Configuration dans **/ | ||
| Ligne 438: | Ligne 456: | ||
| systemctl restart postfix | systemctl restart postfix | ||
| + | On vérifie | ||
| + | < | ||
| + | ss -tlpn | grep 587 | ||
| + | LISTEN 0 100 0.0.0.0: | ||
| + | </ | ||
| + | |||
| + | Dernière étape, comme postfix tourne en chroot (à vérifier dans master.cf) \\ | ||
| + | Modifier le fichier **/ | ||
| + | < | ||
| + | # Example for chroot Postfix users: "-c -m / | ||
| + | # Example for non-chroot Postfix users: "-c -m / | ||
| + | # | ||
| + | # To know if your Postfix is running chroot, check / | ||
| + | # If it has the line "smtp inet n - y - - smtpd" or "smtp inet n - - - - smtpd" | ||
| + | # then your Postfix is running in a chroot. | ||
| + | # If it has the line "smtp inet n - n - - smtpd" then your Postfix is NOT | ||
| + | # running in a chroot. | ||
| + | OPTIONS=" | ||
| + | </ | ||
| + | |||
| + | Postfix ne pourra pas lire non plus le fichier / | ||
| + | cp / | ||
| + | chmod 640 / | ||
| + | chown root:sasl / | ||
| + | systemctl restart postfix | ||
| + | |||
| + | Jusque là, tout semble fonctionner, | ||
| + | < | ||
| + | (host gmail-smtp-in.l.google.com[66.102.1.27] said: | ||
| + | 550-5.7.26 Your email has been blocked because the sender is unauthenticated. | ||
| + | 550-5.7.26 Gmail requires all senders to authenticate with either SPF or DKIM. | ||
| + | 550-5.7.26 | ||
| + | 550-5.7.26 | ||
| + | 550-5.7.26 | ||
| + | 550-5.7.26 | ||
| + | 550-5.7.26 | ||
| + | 550-5.7.26 | ||
| + | 550 5.7.26 | ||
| + | </ | ||