systeme:smtp:relais
Différences
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 | ||
| systeme:smtp:relais [2026/03/28 19:03] – [tester] techer.charles_educ-valadon-limoges.fr | systeme:smtp:relais [2026/03/28 19:23] (Version actuelle) – [utiliser LPIPE pour appeler le script] techer.charles_educ-valadon-limoges.fr | ||
|---|---|---|---|
| Ligne 4: | Ligne 4: | ||
| Application (exemple Documenso) => Postfix (port 25) => Script Python (Communication via LPIPE) => Microsoft Graph API | Application (exemple Documenso) => Postfix (port 25) => Script Python (Communication via LPIPE) => Microsoft Graph API | ||
| - | ===== Prérequis | + | ===== Préparation Azure AD (OAuth2) |
| + | |||
| + | * création d'une **Inscription d' | ||
| + | * Portail Azure => Entra ID | ||
| + | * Inscription d' | ||
| + | * Nom : smtp2graph-relay | ||
| + | * Locataire unique seulement | ||
| + | * S' | ||
| + | |||
| + | * Récupérer : | ||
| + | * Tenant ID | ||
| + | * Client ID | ||
| + | * Ajouter un secret Client (dans Certificates & Secrets) | ||
| + | |||
| + | * Ajouter la permission Microsoft Graph : | ||
| + | * Autorisations d' | ||
| + | |||
| + | * Grant admin consent. | ||
| + | |||
| + | * Adresse email 0365 utilisée pour l’envoi | ||
| + | |||
| + | ===== Installation des prérequis ===== | ||
| + | * conteneur LXC : 2 Gio RAM ; 2 coeurs ; DD de 20 Gio | ||
| + | * modifier le fichier **/ | ||
| + | |||
| + | < | ||
| + | Types: deb | ||
| + | URIs: http:// | ||
| + | Suites: trixie-security | ||
| + | Components: contrib main | ||
| + | Signed-By: / | ||
| + | |||
| + | Types: deb | ||
| + | URIs: http:// | ||
| + | Suites: trixie trixie-updates | ||
| + | Components: contrib main | ||
| + | Signed-By: / | ||
| + | </ | ||
| + | *. installer les paquets pour le script | ||
| < | < | ||
| apt install mailutils libsasl2-modules | apt install mailutils libsasl2-modules | ||
| Ligne 275: | Ligne 313: | ||
| # | # | ||
| #relayhost = | #relayhost = | ||
| + | |||
| + | # Postfix doit écouter sur toutes les interfaces | ||
| + | inet_interfaces = all | ||
| + | |||
| + | # Autoriser l’IP des serveurs client | ||
| + | mynetworks = 127.0.0.0/8 9.9.9.0/24 | ||
| + | |||
| + | # Postfix doit accepter les mails : | ||
| + | smtpd_recipient_restrictions = permit_mynetworks, | ||
| + | |||
| transport_maps = hash:/ | transport_maps = hash:/ | ||
| Ligne 316: | Ligne 364: | ||
| journalctl -u postfix -n 50 | journalctl -u postfix -n 50 | ||
| </ | </ | ||
| - | ===== Préparation Azure AD (OAuth2) ===== | ||
| - | * création d'une **Inscription d' | + | |
| - | * Portail Azure => Entra ID | + | |
| - | * Inscription d' | + | |
| - | * Nom : smtp2graph-relay | + | |
| - | * Locataire unique seulement | + | |
| - | * S' | + | |
| - | + | ||
| - | * Récupérer : | + | |
| - | * Tenant ID | + | |
| - | * Client ID | + | |
| - | * Ajouter un secret Client (dans Certificates & Secrets) | + | |
| - | + | ||
| - | * Ajouter la permission Microsoft Graph : | + | |
| - | * Autorisations d' | + | |
| - | + | ||
| - | * Grant admin consent. | + | |
| - | + | ||
| - | * Adresse email 0365 utilisée pour l’envoi | + | |
| - | + | ||
| - | ===== Installation des prérequis ===== | + | |
| - | * conteneur LXC : 2 Gio RAM ; 2 coeurs ; DD de 20 Gio | + | |
| - | * modifier le fichier **/ | + | |
| - | + | ||
| - | < | + | |
| - | Types: deb | + | |
| - | URIs: http:// | + | |
| - | Suites: trixie-security | + | |
| - | Components: contrib main | + | |
| - | Signed-By: / | + | |
| - | + | ||
| - | Types: deb | + | |
| - | URIs: http:// | + | |
| - | Suites: trixie trixie-updates | + | |
| - | Components: contrib main | + | |
| - | Signed-By: / | + | |
| - | </ | + | |
| - | + | ||
| - | * ajouter les dépôts | + | |
| - | + | ||
| - | < | + | |
| - | # Add Docker' | + | |
| - | apt update | + | |
| - | apt install ca-certificates curl | + | |
| - | install -m 0755 -d / | + | |
| - | curl -fsSL https:// | + | |
| - | chmod a+r / | + | |
| - | + | ||
| - | # Add the repository to Apt sources: | + | |
| - | tee / | + | |
| - | Types: deb | + | |
| - | URIs: https:// | + | |
| - | Suites: $(. / | + | |
| - | Components: stable | + | |
| - | Signed-By: / | + | |
| - | EOF | + | |
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | * mettre à jour | + | |
| - | + | ||
| - | < | + | |
| - | apt update && apt upgrade -y | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | * installer Docker | + | |
| - | + | ||
| - | < | + | |
| - | apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | + | |
| - | </ | + | |
| - | + | ||
| - | * Vérifier l' | + | |
| - | + | ||
| - | < | + | |
| - | docker --version | + | |
| - | docker compose version | + | |
| - | </ | + | |
| - | + | ||
| - | ===== Postfix & 1smtp2graph ===== | + | |
| - | + | ||
| - | * utilisation d'un Docker compose | + | |
| - | + | ||
| - | <code file docker-compose.yml> | + | |
| - | services: | + | |
| - | postfix: | + | |
| - | image: boky/ | + | |
| - | container_name: | + | |
| - | restart: unless-stopped | + | |
| - | environment: | + | |
| - | - ALLOW_EMPTY_SENDER=true | + | |
| - | volumes: | + | |
| - | - ./ | + | |
| - | - ./ | + | |
| - | network_mode: | + | |
| - | + | ||
| - | smtp2graph: | + | |
| - | image: ghcr.io/ | + | |
| - | container_name: | + | |
| - | restart: unless-stopped | + | |
| - | environment: | + | |
| - | PROXY_LISTEN_ADDRESS: | + | |
| - | OAUTH2_TENANT_ID: | + | |
| - | OAUTH2_CLIENT_ID: | + | |
| - | OAUTH2_CLIENT_SECRET: | + | |
| - | OAUTH2_SENDER: | + | |
| - | ports: | + | |
| - | - " | + | |
| - | + | ||
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | ==== postfix/ | + | |
| - | + | ||
| - | < | + | |
| - | # Postfix minimal relay to smtp2graph | + | |
| - | myhostname = postfix-relay.lan | + | |
| - | mydomain = lan | + | |
| - | myorigin = / | + | |
| - | mydestination = | + | |
| - | relayhost = [127.0.0.1]: | + | |
| - | + | ||
| - | smtp_tls_security_level = may | + | |
| - | smtp_sasl_auth_enable = no | + | |
| - | + | ||
| - | # Generic mapping (optionnel pour réécrire root@...) | + | |
| - | smtp_generic_maps = hash:/ | + | |
| - | </ | + | |
| - | + | ||
| - | ==== / | + | |
| - | + | ||
| - | < | + | |
| - | root@postfix-relay.lan | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | Puis : | + | |
| - | < | + | |
| - | postmap / | + | |
| - | </ | + | |
| - | + | ||
| - | ==== postfix/ | + | |
| - | + | ||
| - | < | + | |
| - | smtp inet n | + | |
| - | pickup | + | |
| - | cleanup | + | |
| - | qmgr unix n | + | |
| - | rewrite | + | |
| - | bounce | + | |
| - | defer | + | |
| - | trace | + | |
| - | verify | + | |
| - | flush | + | |
| - | proxymap | + | |
| - | proxywrite unix - | + | |
| - | smtp unix - | + | |
| - | relay | + | |
| - | discard | + | |
| - | </ | + | |
| - | + | ||
| - | On laisse Postfix en mode simple (no chroot) pour éviter les soucis SASL/TLS. | + | |
| - | + | ||
| - | ==== Configuration Documenso ==== | + | |
| - | + | ||
| - | Dans .env : | + | |
| - | < | + | |
| - | NEXT_PRIVATE_SMTP_TRANSPORT=" | + | |
| - | NEXT_PRIVATE_SMTP_HOST=" | + | |
| - | NEXT_PRIVATE_SMTP_PORT=" | + | |
| - | NEXT_PRIVATE_SMTP_SECURE=" | + | |
| - | NEXT_PRIVATE_SMTP_UNSAFE_IGNORE_TLS=" | + | |
| - | NEXT_PRIVATE_SMTP_FROM_ADDRESS=" | + | |
| - | NEXT_PRIVATE_SMTP_FROM_NAME=" | + | |
| - | </ | + | |
| - | ===== Créer un compte Resend ===== | + | |
| - | Lien : https:// | + | |
| - | + | ||
| - | + | ||
| - | * générer une clé d' | + | |
| - | + | ||
| - | ===== Créer un compte SendGrid ===== | + | |
| - | Lien : https:// | + | |
| - | + | ||
| - | + | ||
| - | * générer une clé d' | + | |
| - | + | ||
| - | ===== Installer et confoigurer Postfix ===== | + | |
| - | + | ||
| - | < | + | |
| - | apt update | + | |
| - | apt install postfix mailutils libsasl2-modules | + | |
| - | </ | + | |
| - | + | ||
| - | * Créer le fichier / | + | |
| - | + | ||
| - | < | + | |
| - | [smtp.sendgrid.net]: | + | |
| - | </ | + | |
| - | + | ||
| - | < | + | |
| - | postmap / | + | |
| - | chmod 600 / | + | |
| - | </ | + | |
| - | + | ||
| - | * copier les modules SASL dans le CHROOT | + | |
| - | + | ||
| - | < | + | |
| - | mkdir -p / | + | |
| - | cp -a / | + | |
| - | </ | + | |
| - | ===== Configurer Postfix en “SMTP relay” vers Microsoft 365 ===== | + | |
| - | + | ||
| - | * éditer **/ | + | |
| - | + | ||
| - | < | + | |
| - | nano / | + | |
| - | </ | + | |
| - | + | ||
| - | * Ajoute / remplace : | + | |
| - | + | ||
| - | < | + | |
| - | relayhost = [smtp.sendgrid.net]: | + | |
| - | + | ||
| - | smtp_sasl_auth_enable = yes | + | |
| - | smtp_sasl_password_maps = hash:/ | + | |
| - | smtp_sasl_security_options = noanonymous | + | |
| - | smtp_use_tls = yes | + | |
| - | smtp_tls_security_level = encrypt | + | |
| - | smtp_tls_CAfile = / | + | |
| - | + | ||
| - | + | ||
| - | inet_interfaces = all | + | |
| - | inet_protocols = ipv4 | + | |
| - | </ | + | |
| - | + | ||
| - | < | + | |
| - | systemctl restart postfix | + | |
| - | </ | + | |
systeme/smtp/relais.1774721036.txt.gz · Dernière modification : 2026/03/28 19:03 de techer.charles_educ-valadon-limoges.fr
