Outlook SMTP Server Issues (SMTPSyntaxError)

Hello all!

I’ve been working around and trying to spin up a self-hosted instance of Discourse on a CentOS server. For the most part, things look to be good, as I’ve got the hostname and other things all configured, and the Docker container spins up and I’m able to access my Discourse instance within my local network at http://discourse.foo.co.

However, this is where I’m a bit stuck since I am unable to create my first user since the SMTP settings I’m using seem to not work and is constantly throwing a Net::SMTPSyntaxError, not matter what I try.

My SMTP settings in the app.yml is:

## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'brian@foo.co'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: foo.mail.protection.outlook.com
  DISCOURSE_SMTP_PORT: 25
  DISCOURSE_SMTP_USER_NAME: user@foo.co
  DISCOURSE_SMTP_PASSWORD: a password that contains some special characters '@' and '/'. The password does not contain the '#' special character.
  DISCOURSE_SMTP_AUTHENTICATION: login
  DISCOURSE_SMTP_ENABLE_START_TLS: true         # (optional, default true)
  #DISCOURSE_SMTP_DOMAIN: discourse.example.com    # (required by some providers)
  DISCOURSE_NOTIFICATION_EMAIL: 'community@foo.co'    # (address to send notifications from)

I’ve looked everywhere on the Discourse forums however searching ‘SMTPSyntaxError’ doesn’t return any results for me. On Google, I can’t seem to find solutions that help either.

The same SMTP settings, when entered into our Bamboo and Jira servers work perfectly find and are able to send emails perfectly fine.

I’ve also used testing tools online such as https://dnschecker.org/smtp-test-tool.php and it is able to send test emails perfectly fine. For example, entering the same details shown above sends a test email with the following contents successfully to my inbox.

SMTP host: foo.mail.protection.outlook.com.
Port: 25
Use Explicit TLS encryption: No
Use Implicit TLS/SSL encryption:
Use Authentication: No
Email from: test@foo.co
Email to: brian@foo.co

Any help would be appreciated, thank you,
Brian

I would advise to dump the traffic going from your container to the SMTP server so you can see exactly what’s happening on the wire.

You can trigger an email by running inside the container:

rake 'emails:test[your.email.address@your.domain]' 

and you should see e.g.:

root@michael-discourse-docker-app:/var/www/discourse# rake 'emails:test[michael@contoso.com]'
Testing sending to michael@contoso.com using mail.contoso.net:587, username:michael with plain auth.
SMTP server connection successful.
Sending to michael@contoso.com. . . 
Mail accepted by SMTP server.
Message-ID: e7adb5c4-f404-4800-b070-631b06ff5335@mx1.contoso.com

Which might also give you some clues.

3 Likes

Hi Michael,

Thanks for your suggestion, but it seems to give the same error it gives when I use ./discourse-doctor.

root@discourse-app:/var/www/discourse# rake 'emails:test[brian.lui@foo.co]'
Testing sending to brian.lui@foo.co using foo.mail.protection.outlook.com:25, username:user@foo.co with login auth.
======================================== ERROR ========================================
                                    UNEXPECTED ERROR

Net::SMTPSyntaxError

====================================== SOLUTION =======================================
This is not a common error. No recommended solution exists!

Please report the exact error message above to https://meta.discourse.org/
(And a solution, if you find one!)
=======================================================================================

Brian

When I run the command inside the container (as I saw in the Discourse SMTP troubleshooting guide):

openssl s_client -connect foo.mail.protection.outlook.com:25 -starttls smtp

Everything looks normal but instead of a 250 DSN, I see a 250 SMTPUTF8. Then when I try to enter the command EHLO "i am here", nothing happens and I eventually time out:

451 4.7.0 Timeout waiting for client input [YT1PEPF00001E8C.CANPRD01.PROD.OUTLOOK.COM 2024-02-23T17:51:16.770Z 08DC342D15BDD245] read:errno=0

I get the same result.

I don’t really have any suggestions other than this seems to be a problem with the mail server itself rather than Discourse.

I wouldn’t expect this server to be used for mail submission. Are you sure this is correct?

I see that other people have used a different submission server and gotten that working:

2 Likes