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.
I use socketlabs.com as my email delivery service, and had a similar issue. In my case the solution was to edit lib/tasks/emails.rake as follows:
Change the line: Net::SMTP.start(smtp[:address], smtp[:port], 'localhost', smtp[:user_name], smtp[:password])
to Net::SMTP.start(smtp[:address], smtp[:port], 'localhost', smtp[:user_name], smtp[:password], smtp[:authentication])
Without this change, the DISCOURSE_SMTP_AUTHENTICATION: login doesnât get passed to the lower level SMTP code.
I havenât tested this to see if the modified code still works for other authentication methods, but it fixes the problem for login authentication.
I can confirm, that adding smtp[:authentication]
to Net::SMTP.start call and setting DISCOURSE_SMTP_AUTHENTICATION: login
in app.yml fixes the issue for email test page.
I believe, that regular emails are send via mail library, and setting DISCOURSE_SMTP_AUTHENTICATION: login
in app.yml is enough for the library to work correctly.
Still, I believe, that lib/tasks/emails.rake should be patched to use DISCOURSE_SMTP_AUTHENTICATION setting. This would save some unnecessary debugging .
As a general update on this issue, MS are in the process of removing legacy authentication for SMTP and POP3 which is going to make things difficult if you are using O365 as a mail provider. The default policy applied now is to prohibit SMTP AUTH and you need to enable this per-mailbox. Hope thatâs useful â I spent yesterday morning banging my head against this wall.
Itâs a real shame about POP in particular, because setting up inbound mail is going to get a lot harder unless Discourse adds IMAP support for inbound mailboxes.
Thereâs an easy solution for incoming mail that includes a container to receive it. It used to be called "straightforward "but someone objected to the name and it was changed and I canât find it anymore.
Well, running your own mail server should be considered a method of last resort in any case. I believe it was âdirect deliveryâ, try searching for that.