Sending emails not working

My digitalocean discourse droplet can’t send mails. The error I get is:

Delivered mail d8f9bf03-a3ce-4b42-8226-fc4f40a9c724@foo.barbar.com (5099.4ms)

Job exception: 504 5.7.4 Unrecognized authentication type [BL0PR0102CA0036.prod.exchangelabs.com]

My settings are:

  DISCOURSE_SMTP_ADDRESS: smtp.office365.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: foo@bar.com
  DISCOURSE_SMTP_PASSWORD: "mypassword"
  DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)

I have tried telnet from the droplet and it gives no errors:
telnet smtp.office365.com 587

What could be the problem? I have tried the smtp settings combination locally from python and it works so I assume that’s not the problem.

Hi,
Try to add:

  DISCOURSE_SMTP_AUTHENTICATION: login

And at end of app.yml:

 - exec: rails r "SiteSetting.notification_email='foo@bar.com'"`
1 Like

Hi mik
The exec statement fails:

FAILED

--------------------

Pups::ExecError: rails r "SiteSetting.notification_email='foo@bar.com'"` failed with return #<Process::Status: pid 2229 exit 2>

Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'

exec failed with the params "rails r \"SiteSetting.notification_email='foo@bar.com'\"`"

9628e31c775b74ad0f3a555b6af27701aa40b1f8b86419fa44a7c389cc5e34ae

** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

./discourse-doctor may help diagnose the problem.

Update leaving out the exec command but adding:

  DISCOURSE_SMTP_AUTHENTICATION: login

does not produce return an error I only get:
Delivered mail be6d8718-5445-48cc-a120-6d6d1eab9eb7@discourse.bar.com (4307.2ms)

But I still don’t get an email in my inbox (I checked the spam folder)

You can try this in order to try to find the good configuration and perhaps have some error message:

docker exec -t -i  id_of_your_container /bin/bash

Then inside the container:

apt install s-nail
echo "This is the message body and contains the message" | s-nail -r "foo@bar.com" -s mysubject -S "smtp=smtp.office365.com:587" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="foo@bar.com" -S smtp-auth-password="xxxxxxxx" -S ssl-verify=ignore youremail@example.com

You can change the different value (ie : smtp-auth=login ) to try to find the good one. And perhaps you will have more precise error message.

2 Likes
echo "This is the message body and contains the message" | s-nail -r "foo@bar.com" -s mysubject -S "smtp=smtp.office365.com:587" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="foo@bar.com" -S smtp-auth-password="xxxxxxxx" -S ssl-verify=ignore youremail@example.com

This worked and I got the mail! I had to change the smtp-auth-password=“xxxxxxxx” to single quotes though since my password starts with an ‘!’.

The only difference I can see to my config is this flag:
-S ssl-verify=ignore

Do I have to add that too?
Thanks for your help!

Try to add:

DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

In your config, it is the same as ssl-verify=ignore .

No errors but still no email in the inbox :frowning: To recap, this is my config now:

  DISCOURSE_SMTP_ADDRESS: smtp.office365.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: info@foo.com
  DISCOURSE_SMTP_PASSWORD: 'xxx'
  DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  DISCOURSE_SMTP_AUTHENTICATION: login
  DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

Please try to add this again (it is the same as “-r” option in the s-nail command line test :

  - exec: rails r "SiteSetting.notification_email='foo@bar.com'"`

The email must be the same as your account.

And check the indentation in the file app.yml, and do not forget the “-” at the beginning. There is 2 space then the “-” then a space then “exec…” :slight_smile:

I’m having this problem also. I spun up a droplet with Discourse on Digital Ocean as well. I used the “sudo ./discourse-doctor” command after trying all of these suggestions and rebuilding each time ( sudo ./launcher rebuild app).

504 5.7.4 Unrecognized authentication type [BL0PR01CA0015.prod.exchangelabs.com]

s-nail from within the container did work for me also, no problem. And I tried it without the “-S ssl-verify=ignore” clause, worked fine. Can someone verify that what gets installed on the digital ocean droplet does send email correctly?

Find out from your mail admins what the valid values of smtp_authentication are, and set DISCOURSE_SMTP_AUTHENTICATION to one that works.

1 Like

Thanks for all the help, I have given up and switched to another forum solution.

1 Like

It is Microsoft, their instructions are as follows, no smtp_authentication is specified;

Do you not support this kind of server? Can you simply make an account, connect to it, and tell us what the settings should be?

DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

This solved my issue thanks!

1 Like