SMTP con Office365?

Hello

I try to use Office365 as SMTP for discourse. I’m already using this account for my wordpress SMTP so the account is not the problem.

When i try to send a email test, an error message appear

[Sender] 504 5.7.4 Unrecognized authentication type [AM3PR05CA0123.eurprd05.prod.outlook.com]

This is my SMTP config from app.yml

## TODO: The SMTP mail server used to validate new accounts and send notifications
DISCOURSE_SMTP_ADDRESS: smtp.office365.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: test@example.fr
DISCOURSE_SMTP_PASSWORD: password
DISCOURSE_SMTP_AUTHENTICATION: login
DISCOURSE_SMTP_ENABLE_START_TLS: false 

Any idea how to fix the problem ?

Another config:

## TODO: The SMTP mail server used to validate new accounts and send notifications
DISCOURSE_SMTP_ADDRESS: smtp.office365.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: test@example.fr
DISCOURSE_SMTP_PASSWORD: password
DISCOURSE_SMTP_AUTHENTICATION: login
DISCOURSE_SMTP_ENABLE_START_TLS: true

I get the following error:

550 5.7.60 SMTP; Client does not have permissions to send as this sender

The problem is from Discourse, because I can test with swaks and it’s working

swaks --to test@example.com --from test2@example.com --server smtp.office365.com --auth login --auth-user test2@example.com -tls

Not Suggesting that You use office365 for SMTP but it seems like DISCOURSE_SMTP_AUTHENTICATION: login isn’t required … maybe try commenting that out and try again with STARTTLS set to True?

Okay the problem is now fixed. Huge mistake from my side : the email from Admin → settings → notification email was not the same from the smtp username.
Maybe a check should be made to prevent user to makes this mistake :face_with_raised_eyebrow:

but it seems like DISCOURSE_SMTP_AUTHENTICATION: login isn’t required

True, the final config

DISCOURSE_SMTP_ADDRESS: smtp.office365.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: test@example.fr
DISCOURSE_SMTP_PASSWORD: password
DISCOURSE_SMTP_AUTHENTICATION: login
DISCOURSE_SMTP_ENABLE_START_TLS: true
4 Mi Piace

Discourse cannot guess what addresses the mail server will deliver for.

4 Mi Piace

Sadly this solution is not working for me (I also tried to escape the password). I tried it with this SMTP setting problem with Office365 - #5 by ianwhite one which is working. But not everybody gets E-Mails… :thinking:

If some people get mail then it’s the fault of office365, or their mail provider. The others should check their spam folder, though if they use a service life office365 it will silently drop mail that it thinks is spam.

I tried it with these settings. In the skipped section in the email tab I can see the following error:

554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied;

Sounds like the address you are sending from is not one that the mail server supports. There is a line at the bottom of app.yml that week let you set the notification address. (you can set it in sure settings if you’re logged in)

2 Mi Piace

Or maybe they have VERP enabled so the email address is replies+{key}@example.com instead of the authorized noreply@example.com That was the issue I’ve faced in past while trying to send mails from my own mail server. It’s usually easy to fix though.

2 Mi Piace

Yes. This worked for me. Two things in the initial setup:

DISCOURSE_SMTP_USER_NAME:
-- AND --
DISCOURSE_NOTIFICATION_EMAIL:

needed to be set to the same email.

1 Mi Piace

Istruzioni aggiornate per chi ha problemi con Office 365 e la consegna diretta

  • Vai al Centro amministrazione Microsoft
  • Fai clic su Impostazioni, quindi su Domini
  • Fai clic su Aggiungi dominio
  • Segui le istruzioni sullo schermo per aggiungere l’URL del tuo forum (esempio: forum:iltuolink.com)
  • Una volta completati i passaggi precedenti e verificato il DNS, sarai in grado di creare una casella di posta utilizzando tale sottodominio
  • Fai clic su Utenti, quindi su Utenti attivi
  • Fai clic su Aggiungi un utente
  • Crea la mailbox per il tuo forum (esempio: noreply@forum.iltuolink.com) il dominio della mailbox deve corrispondere all’hostname da cui è in esecuzione il forum
  • Fai clic su Licenze e App
  • Assegna a questa mailbox una licenza Exchange Online (Piano 1) (10.000 messaggi giornalieri, limite di 30 messaggi/minuto). È necessario disporre di una licenza associata alla mailbox per la consegna diretta. Al momento della stesura, il costo è di $4,00 USD/mese o $5,10/CAD | Se hai bisogno di un limite più alto o di un limite di tempo più breve, sono disponibili altri piani
  • Fai clic su Posta, quindi su Gestisci app di posta elettronica
  • Abilita “SMTP autenticato”
  • Fai clic su Salva modifiche
  • Vai al tuo portale Azure
  • Vai alla tua directory attiva
  • Seleziona Proprietà nella barra laterale sinistra, appena sotto Impostazioni utente
  • Seleziona Gestisci impostazioni di sicurezza
  • Imposta le Impostazioni di sicurezza su “disabilitato”
  • Fai clic su Salva
  • Torna a Utenti > Utenti attivi
  • Fai clic su Autenticazione a più fattori
  • Disabilita l’MFA sulla mailbox in uso

La mailbox è ora pronta per essere utilizzata dal tuo Discourse.

1 Mi Piace

Imposta le impostazioni di sicurezza su “disabilitato”

Questa era l’unica cosa che impediva l’autenticazione SMTP…
Mi sono sbattuto la testa contro un muro per giorni…
Perché Microsoft rende le cose così difficili…?

Disabilitare i valori predefiniti di sicurezza potrebbe non essere più necessario con l’applicazione dell’MFA. Se abiliti e quindi applichi l’MFA a un account M365, puoi andare alla pagina di configurazione MFA dell’account e aggiungere una password per le app da utilizzare per bypassare l’MFA. Sono riuscito a farlo funzionare con un utente con licenza M365 Business Basic con applicazione MFA, autenticazione SMTP e valori predefiniti di sicurezza tutti abilitati. Ho solo dovuto aumentare i timeout di apertura e lettura SMTP con due righe aggiuntive. 30 potrebbe essere eccessivo, ma 5 era troppo poco.

Voce app.yml funzionante, a settembre 2023:

  DISCOURSE_SMTP_ADDRESS: smtp.office365.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: user@domain.com
  DISCOURSE_SMTP_PASSWORD: whatever-your-app-password-is
  DISCOURSE_SMTP_AUTHENTICATION: login
  DISCOURSE_SMTP_ENABLE_START_TLS: true
  DISCOURSE_NOTIFICATION_EMAIL: user@domain.com
  DISCOURSE_SMTP_OPEN_TIMEOUT: 30
  DISCOURSE_SMTP_READ_TIMEOUT: 30
1 Mi Piace

Questo argomento è stato chiuso automaticamente dopo 2343 giorni. Non sono più consentite nuove risposte.