SMTP with office365?


(Martial) #1

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

(Bhanu Sharma) #2

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?


(Martial) #3

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

(Jay Pfaffman) #4

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