SMTP mit 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 „Gefällt mir“

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

4 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

Einige aktuelle Anweisungen für alle, die Probleme mit Office 365 und Direct-Delivery haben

  • Gehen Sie zum Microsoft Admin Center
  • Klicken Sie auf Einstellungen und dann auf Domänen
  • Klicken Sie auf Domäne hinzufügen
  • Folgen Sie den Anweisungen auf dem Bildschirm, um die URL Ihres Forums hinzuzufügen (Beispiel: forum:yourlinks.com)
  • Sobald Sie die obigen Schritte ausgeführt und die DNS-Überprüfung abgeschlossen haben, können Sie nun eine E-Mail-Adresse mit dieser Subdomäne erstellen
  • Klicken Sie auf Benutzer und dann auf Aktive Benutzer
  • Klicken Sie auf Benutzer hinzufügen
  • Erstellen Sie das Postfach für Ihr Forum (Beispiel: noreply@forum.yourlinks.com). Die Postfachdomäne muss mit dem Hostnamen übereinstimmen, von dem aus das Forum ausgeführt wird.
  • Klicken Sie auf Lizenzen & Apps
  • Weisen Sie diesem Postfach eine Exchange Online (Plan 1)-Lizenz zu (10.000 Nachrichten täglich, 30 Nachrichten/Minute Drosselung). Es ist erforderlich, dass dem Postfach eine Lizenz für die Direct-Delivery zugeordnet ist. Zum Zeitpunkt der Erstellung dieses Dokuments betragen die Kosten 4,00 USD/Monat oder 5,10 CAD. Sollten Sie ein höheres Limit oder eine kürzere Drosselung benötigen, sind andere Pläne verfügbar.
  • Klicken Sie auf Mail und dann auf E-Mail-Apps verwalten
  • Aktivieren Sie “Authentifizierte SMTP”
  • Klicken Sie auf Änderungen speichern
  • Gehen Sie zu Ihrem Azure-Portal
  • Navigieren Sie zu Ihrem Active Directory
  • Wählen Sie im linken Seitenmenü Eigenschaften aus, direkt unter Benutzereinstellungen
  • Wählen Sie Sicherheitsstandards verwalten
  • Deaktivieren Sie Sicherheitsstandards
  • Klicken Sie auf Speichern
  • Gehen Sie zurück zu Benutzer > Aktive Benutzer
  • Klicken Sie auf Mehrstufige Authentifizierung
  • Deaktivieren Sie die MFA für das verwendete Postfach

Das Postfach ist nun für die Verwendung durch Ihr Discourse bereit.

1 „Gefällt mir“

„Sicherheitsstandards auf „deaktiviert“ setzen“

Dies war das Einzige, was die SMTP-Authentifizierung verhinderte …
Ich habe mir tagelang den Kopf zerbrochen …
Warum macht MS die Dinge so schwierig…?

Das Deaktivieren von Sicherheitsstandardeinstellungen ist mit der Erzwingung von MFA möglicherweise nicht mehr erforderlich. Wenn Sie MFA für ein M365-Konto aktivieren und dann erzwingen, können Sie zur MFA-Einrichtungsseite des Kontos gehen und ein App-Passwort hinzufügen, um MFA zu umgehen. Ich habe es mit einem Benutzer mit M365 Business Basic-Lizenz zum Laufen gebracht, bei dem MFA-Erzwingung, SMTP AUTH und Sicherheitseinstellungen alle aktiviert waren. Ich musste nur die SMTP-Open- und Read-Timeouts mit zwei zusätzlichen Zeilen erhöhen. 30 mag übertrieben sein, aber 5 war zu wenig.

Funktionierender app.yml-Eintrag, Stand September 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 „Gefällt mir“

Dieses Thema wurde nach 2343 Tagen automatisch geschlossen. Neue Antworten sind nicht mehr möglich.