SMTP setting problem with Office365

AI 生成的摘要

SMTP Setting Problem with Office365

jianwei.lu is encountering issues setting up Email SMTP using Office365’s online email server. Despite using the correct SMTP settings, emails cannot be sent, resulting in a “504 5.7.4 Unrecognized authentication type” error.

kraml suggests that the issue might be due to a non-ASCII quotation mark in the password field, but jianwei.lu confirms this was an editing mistake.

mpalmer notes that Office365’s authentication options might not be compatible with Discourse’s SMTP library and advises against using mailbox providers like Office365 for outgoing email due to potential terms of service violations.

ianwhite provides a working setup for an Office365 SMTP relay, which includes using a whitelisted domain and the following settings:

  • DISCOURSE_SMTP_ADDRESS: <yourdomainkey>.mail.protection.outlook.com
  • DISCOURSE_SMTP_PORT: 25
  • DISCOURSE_SMTP_DOMAIN: <yourdomain>
  • DISCOURSE_SMTP_ENABLE_STARTTLS_AUTO: true

I encounter a problem when I try to set the Email SMTP using Office365 online email server.

the SMTP setting of Office365 is:

Server name: smtp.partner.outlook.cn
Port: 587
Encryption method: STARTTLS

The discourse’s SMTP setting in the container/app.yml as below:

DISCOURSE_SMTP_ADDRESS: smtp.partner.outlook.cn
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: xxxx@xxxx.com
DISCOURSE_SMTP_PASSWORD: “xxxxxxxx"
DISCOURSE_SMTP_ENABLE_START_TLS: true       

The email can not be sent, and I found a error message in logs:

Sent mail to receiver@abc.com (5739.7ms)
Job exception: 504 5.7.4 Unrecognized authentication type [SHAPR01CA004.CHNPR01.prod.partner.outlook.cn]

and I also tried this way, still doesn’t work:

DISCOURSE_SMTP_ADDRESS: xxxx-com.mail.protection.partner.outlook.cn
DISCOURSE_SMTP_PORT: 25
DISCOURSE_SMTP_USER_NAME: xxxx@xxxx.com
DISCOURSE_SMTP_PASSWORD: “xxxxxxxx"
DISCOURSE_SMTP_ENABLE_START_TLS: false          # (optional, default true)

Anyone can help me?

In this line I noticed the first quotation mark is not the ASCII quotation mark of code 0x22, it is a Chinese one.

Oh, yes. It’s my mistake when I edit this post, but not happened in the real environment.
Thanks!

Presumably the set of authentication options which office365 supports doesn’t include any of the options that Discourse (or, rather, the SMTP library that Discourse uses) supports. What authentication modes does Office365 support?

Also, note that we don’t recommend using a mailbox provider such as Office365 or gmail for outgoing e-mail, as it is usually a violation of the provider’s terms of service, and often balks at sending the volume of mail that Discourse generates.

I have been setting up an SMTP relay for an Office365 server, and eventually found the following combination to work. The setup on the O365 side was a whitelisted domain.

DISCOURSE_SMTP_ADDRESS: <yourdomainkey>.mail.protection.outlook.com
DISCOURSE_SMTP_PORT: 25
DISCOURSE_SMTP_DOMAIN: <yourdomain>
DISCOURSE_SMTP_ENABLE_STARTTLS_AUTO: true

Hope that helps.