SMTP: Nicht erkannte Authentifizierungsart mit Office 365

Ich erhalte diesen Fehler und habe bereits so viele verschiedene Optionen ausprobiert. Ich verwende Office 365.

Fehler: 504 5.7.4 Nicht erkannte Authentifizierungsmethode [MN2PR20CA0010.namprd20.prod.outlook.com]

Einstellungen hier:

  DISCOURSE_SMTP_ADDRESS: smtp.office365.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: email
  DISCOURSE_SMTP_PASSWORD: "PASSWORD"
  DISCOURSE_SMTP_ENABLE_START_TLS: true

try your configuration using openssl tool first

  1. Encode your office365 user
echo -n "your email here " | openssl enc -base64
xxx_encoded_email_xxx

2.Encode your password

echo -n "your password here" | openssl enc -base64
xxx_encoded_password_xxx

3.Open a connection

openssl s_client -connect SMTP.office365.com:587 -starttls smtp -quiet -crlf

4.Test authentification

  • wait for the message 250 SMTPUTF8
  • send EHLO SMTP.office365.com
  • wait for response
    250-PR3P189CA0029.outlook.office365.com Hello [88.138.0.68]
    250-SIZE 157286400
    250-PIPELINING
    250-DSN
    250-ENHANCEDSTATUSCODES
    250-AUTH LOGIN XOAUTH2
    250-8BITMIME
    250-BINARYMIME
    250-CHUNKING
    250 SMTPUTF8
    
  • send AUTH LOGIN
  • wait for 334 VXNlcm5hbWU6
  • send your encoded user login xxx_encoded_email_xxx
  • wait for 334 UGFzc3dvcmQ6
  • send your encoded password xxx_encoded_password_xxx
  • wait for response 235 2.7.0 Authentication successful
3 „Gefällt mir“

So if the openssl test works but the connection test run by discourse-doctor still fails when using those settings what is next? Even though the openssl test works my discourse connection still fails with 504 5.7.4 Unrecognized authentication type… Presumably it is not recognizing the LOGIN auth method. I tried adding DISCOURSE_SMTP_AUTHENTICATION: login to the app.yml file, but that has not helped.

FWIW, here is what I have found. I went into the docker image and started monkeying around with the lib/tasks/emails.rake script and the config/discourse.conf file. Several hours later, after trying every possible combination of smtp.office365.com and .mail.protection.outlook.com AUTH login and AUTH plain I uncommented the block above the STMP start.

# We would like to do this, but Net::SMTP errors out using starttls
#Net::SMTP.start(smtp[:address], smtp[:port]) do |s|
#  s.starttls if !!smtp[:enable_starttls_auto] && s.capable_starttls?
#  s.auth_login(smtp[:user_name], smtp[:password])
#end

Running that as-is resulted in a read timeout.
Modifying it like this - calling new rather than start resulted in a successful send.

Net::STMP.new(smtp[:address], smtp[:port]) do |s|
    s.enable_starttls
    s.auth_login(smtp[:user_name], smtp[:password])
end

This is my first exposure to Ruby, rake and friends. I can’t explain why it works or if is a ‘good thing’ for general cases.
J.

Oh, also I never was able to get it to work to the my_domain.mail.protection.outlook.com on either 25 or 587, what worked was smtp.office365.com:587.

1 „Gefällt mir“

Ich nutze socketlabs.com als E-Mail-Versanddienst und hatte ein ähnliches Problem. In meinem Fall bestand die Lösung darin, die Datei lib/tasks/emails.rake wie folgt zu bearbeiten:
Ändern Sie die Zeile:
Net::SMTP.start(smtp[:address], smtp[:port], 'localhost', smtp[:user_name], smtp[:password])
in:
Net::SMTP.start(smtp[:address], smtp[:port], 'localhost', smtp[:user_name], smtp[:password], smtp[:authentication])

Ohne diese Änderung wird DISCOURSE_SMTP_AUTHENTICATION: login nicht an den darunterliegenden SMTP-Code übergeben.

Ich habe nicht getestet, ob der geänderte Code auch für andere Authentifizierungsmethoden funktioniert, aber er behebt das Problem bei der login-Authentifizierung.

3 „Gefällt mir“

Ich kann bestätigen, dass das Hinzufügen von
smtp[:authentication]
zum Net::SMTP.start-Aufruf und das Setzen von
DISCOURSE_SMTP_AUTHENTICATION: login
in app.yml das Problem auf der E-Mail-Testseite behebt.

Ich gehe davon aus, dass reguläre E-Mails über die mail-Bibliothek gesendet werden und das Setzen von
DISCOURSE_SMTP_AUTHENTICATION: login
in app.yml für die korrekte Funktionsweise der Bibliothek ausreicht.

Dennoch bin ich der Meinung, dass lib/tasks/emails.rake so angepasst werden sollte, dass es die Einstellung DISCOURSE_SMTP_AUTHENTICATION verwendet. Dies würde einige unnötige Fehlersuche einsparen.

1 „Gefällt mir“

Sieht für mich nach einem :bug: aus. Ich habe einen PR eingereicht:

3 „Gefällt mir“

Hallo,

Net::SMTP.start(smtp[:address], smtp[:port], ‘localhost’, smtp[:user_name], smtp[:password], smtp[:authentication])
rescue Exception => e

wurde in meiner aktuellen Version wie oben beschrieben gepatcht, aber der Fehler tritt weiterhin auf.

Fehler: 504 5.7.4 Unbekannter Authentifizierungstyp bei smtp.office365.com.

Hat jemand eine Idee?

1 „Gefällt mir“

Wie bearbeite ich das Skript lib/tasks/emails.rake, damit das funktioniert?

Als allgemeines Update zu diesem Thema: MS entfernt gerade die veraltete Authentifizierung für SMTP und POP3, was die Sache erschweren wird, wenn Sie O365 als E-Mail-Anbieter nutzen. Die derzeit angewendete Standardrichtlinie verbietet SMTP AUTH, und Sie müssen dies pro Postfach aktivieren. Ich hoffe, das ist hilfreich – ich habe gestern Morgen stundenlang gegen diese Wand gelaufen.

Besonders schade ist das für POP, denn die Einrichtung von eingehender E-Mail wird deutlich schwieriger, es sei denn, Discourse fügt IMAP-Unterstützung für eingehende Postfächer hinzu.

1 „Gefällt mir“

Es gibt eine einfache Lösung für eingehende E-Mails, die einen Container zum Empfangen enthält. Früher hieß sie ‘einfach’, aber jemand hat den Namen beanstandet, er wurde geändert, und ich kann ihn nicht mehr finden.

Es gibt auch IMAP-Unterstützung für Gruppen-Postfächer. Diese unterstützt jedoch hauptsächlich nur Gmail.

3 „Gefällt mir“

Nun, den eigenen Mailserver zu betreiben, sollte in jedem Fall als letztes Mittel betrachtet werden. Ich glaube, es ging um „direkte Zustellung

2 „Gefällt mir“

Stand 2023 ist die POP3-Authentifizierung in Exchange nicht mehr möglich.

1 „Gefällt mir“

Wenn Sie PHPMailer verwenden
Versuchen Sie dann, die Zeile auszukommentieren/zu entfernen und versuchen Sie es: //$mail->isSMTP(true);