diff --git a/.env.example b/.env.example index 41c906ee..e14f8d36 100644 --- a/.env.example +++ b/.env.example @@ -120,7 +120,7 @@ SMTP_PORT=587 SMTP_SECURE=false SMTP_USER=admin@tloto.net SMTP_PASS=your-admin-mailbox-password -EMAIL_FROM="Tloto" +EMAIL_FROM="Tloto " EMAIL_REPLY_TO=info@tloto.net VERIFY_EMAIL_PATH=/verify-email RESET_PASSWORD_PATH=/reset-password diff --git a/backend/.env.example b/backend/.env.example index 59ddb1c4..81ce623b 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -79,7 +79,7 @@ PASSWORD_RESET_EXPIRY_HOURS=1 # SMTP_SECURE=false # SMTP_USER=admin@tloto.net # SMTP_PASS=your-mailbox-password-or-app-password -# EMAIL_FROM="Tloto" +# EMAIL_FROM="Tloto " # EMAIL_REPLY_TO=info@tloto.net # Candle Predict engine (performance tuning for production scale) diff --git a/backend/src/scripts/verifySmtp.ts b/backend/src/scripts/verifySmtp.ts index 35de145b..d17de86a 100644 --- a/backend/src/scripts/verifySmtp.ts +++ b/backend/src/scripts/verifySmtp.ts @@ -81,12 +81,22 @@ async function main(): Promise { main().catch((e) => { const msg = e instanceof Error ? e.message : String(e); console.error('SMTP verification failed:', msg); - if (msg.includes('535') || msg.includes('BadCredentials') || msg.includes('Authentication unsuccessful')) { + if ( + msg.includes('SmtpClientAuthentication is disabled') || + msg.includes('smtp_auth_disabled') + ) { + console.error( + '\nMicrosoft 365 blocked SMTP AUTH for this tenant/mailbox.\n' + + ' Enable Authenticated SMTP for admin@tloto.net (M365 admin → user → Mail → Email apps),\n' + + ' or see https://aka.ms/smtp_auth_disabled — then retry verify-smtp.\n' + + ' If MFA is on, use a Microsoft app password in SMTP_PASS.' + ); + } else if (msg.includes('535') || msg.includes('BadCredentials') || msg.includes('Authentication unsuccessful')) { console.error( '\nAuth rejected. Tloto uses Microsoft 365 / GoDaddy only (not Gmail):\n' + ' SMTP_HOST=smtp.office365.com SMTP_PORT=587 SMTP_SECURE=false\n' + - ' SMTP_USER=admin@tloto.net (mailbox password)\n' + - ' EMAIL_FROM="Tloto" (alias / Send As)\n' + + ' SMTP_USER=admin@tloto.net (mailbox password or app password)\n' + + ' EMAIL_FROM="Tloto " (alias / Send As)\n' + ' EMAIL_REPLY_TO=info@tloto.net' ); } diff --git a/docs/DEPLOY-VPS.md b/docs/DEPLOY-VPS.md index fdb8be6c..7c16b049 100644 --- a/docs/DEPLOY-VPS.md +++ b/docs/DEPLOY-VPS.md @@ -285,7 +285,7 @@ SMTP_PORT=587 SMTP_SECURE=false SMTP_USER=admin@tloto.net SMTP_PASS=mot-de-passe-de-la-boite-admin -EMAIL_FROM="Tloto" +EMAIL_FROM="Tloto " EMAIL_REPLY_TO=info@tloto.net APP_PUBLIC_URL=https://tloto.net RESET_PASSWORD_PATH=/reset-password @@ -309,6 +309,38 @@ Contrôler dans la boîte de réception : From = `info@tloto.net`, Reply-To = `i Si erreur du type `SendAsDenied` / `550 5.7.60` : l’alias n’a pas le droit d’envoyer — corriger dans M365/GoDaddy avant de retenter. +#### Erreur `535 5.7.139 … SmtpClientAuthentication is disabled for the Tenant` + +La config Tloto est correcte (`EMAIL_FROM` / `SMTP_USER`), mais **Microsoft 365 bloque SMTP AUTH** sur le tenant (souvent désactivé par défaut). + +Activer SMTP AUTH (une des voies) : + +1. **Pour la boîte `admin@tloto.net` (recommandé)** + - [Microsoft 365 admin center](https://admin.microsoft.com) → **Users** → **Active users** → `admin@tloto.net` + - **Mail** → **Manage email apps** / **Email apps** + - Cocher **Authenticated SMTP** → Save + + Ou PowerShell Exchange Online : + ```powershell + Set-CASMailbox -Identity admin@tloto.net -SmtpClientAuthenticationDisabled $false + ``` + +2. **Au niveau organisation** (si la case boîte est grisée) + - Admin center → **Settings** → **Org settings** → **Modern authentication** / **Mail** + - Ou : [https://aka.ms/smtp_auth_disabled](https://aka.ms/smtp_auth_disabled) + - Autoriser SMTP AUTH pour le tenant, puis réactiver sur la boîte. + +3. Chez **GoDaddy** : Email & Office → Admin / Microsoft 365 → gérer l’utilisateur `admin@` → options de messagerie / SMTP authentifié (libellés varient). + +Attendre 1–15 minutes, puis : + +```bash +sudo npm run phase-b:verify-smtp +sudo docker compose run --rm --no-deps -e SMTP_TEST_TO=votre@email.com backend node dist/scripts/verifySmtp.js +``` + +Si MFA est obligatoire sur le compte : créer un **mot de passe d’application** Microsoft et le mettre dans `SMTP_PASS` (pas le mot de passe de connexion web). + > **Tloto n’utilise plus Gmail** comme expéditeur. Uniquement Microsoft 365 (`admin@` / alias `info@`). > **Ne pas committer `.env`** — il est ignoré par Git.