# Sending emails not working

**URL:** https://meta.discourse.org/t/sending-emails-not-working/149883
**Category:** Self-hosting
**Created:** [April 30, 2020, 9:24am UTC](https://meta.discourse.org/t/sending-emails-not-working/149883 "2020-04-30T09:24:22Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Kristian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kristian/32/178775_2.png) [@Kristian](https://meta.discourse.org/u/Kristian)
#### Post date: [April 30, 2020, 9:24am UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/1 "2020-04-30T09:24:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mik](https://meta.discourse.org/u/mik)
#### Post date: [April 30, 2020, 10:34am UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/2 "2020-04-30T10:34:59Z")

</div>

Hi,  
Try to add:

```
  DISCOURSE_SMTP_AUTHENTICATION: login

```

And at end of app.yml:

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

```

---

<div class="post-metadata">

### Author: ![Kristian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kristian/32/178775_2.png) [@Kristian](https://meta.discourse.org/u/Kristian)
#### Post date: [April 30, 2020, 11:27am UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/3 "2020-04-30T11:27:38Z")

</div>

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.

```

---

<div class="post-metadata">

### Author: ![Kristian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kristian/32/178775_2.png) [@Kristian](https://meta.discourse.org/u/Kristian)
#### Post date: [April 30, 2020, 12:28pm UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/4 "2020-04-30T12:28:49Z")

</div>

Update leaving out the exec command but adding:

```plaintext
  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)

---

<div class="post-metadata">

### Author: ![mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mik](https://meta.discourse.org/u/mik)
#### Post date: [April 30, 2020, 1:34pm UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/5 "2020-04-30T13:34:09Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Kristian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kristian/32/178775_2.png) [@Kristian](https://meta.discourse.org/u/Kristian)
#### Post date: [April 30, 2020, 3:01pm UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/6 "2020-04-30T15:01:54Z")

</div>

```plaintext
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!

---

<div class="post-metadata">

### Author: ![mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mik](https://meta.discourse.org/u/mik)
#### Post date: [April 30, 2020, 3:14pm UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/7 "2020-04-30T15:14:31Z")

</div>

Try to add:

```plaintext
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

```

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

---

<div class="post-metadata">

### Author: ![Kristian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kristian/32/178775_2.png) [@Kristian](https://meta.discourse.org/u/Kristian)
#### Post date: [April 30, 2020, 3:59pm UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/8 "2020-04-30T15:59:39Z")

</div>

No errors but still no email in the inbox ☹ 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

```

---

<div class="post-metadata">

### Author: ![mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mik](https://meta.discourse.org/u/mik)
#### Post date: [April 30, 2020, 4:31pm UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/9 "2020-04-30T16:31:35Z")

</div>

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…” 🙂

---

<div class="post-metadata">

### Author: ![Capstan](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@Capstan](https://meta.discourse.org/u/Capstan)
#### Post date: [May 3, 2020, 1:34am UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/10 "2020-05-03T01:34:48Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [May 3, 2020, 6:32am UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/12 "2020-05-03T06:32:27Z")

</div>

Find out from your mail admins what the valid values of `smtp_authentication` are, and set DISCOURSE\_SMTP\_AUTHENTICATION to one that works.

---

<div class="post-metadata">

### Author: ![Kristian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kristian/32/178775_2.png) [@Kristian](https://meta.discourse.org/u/Kristian)
#### Post date: [May 3, 2020, 9:14am UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/13 "2020-05-03T09:14:52Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Capstan](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@Capstan](https://meta.discourse.org/u/Capstan)
#### Post date: [May 3, 2020, 2:38pm UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/14 "2020-05-03T14:38:44Z")

</div>

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

- SMTP server name [smtp.office365.com](http://smtp.office365.com)
- SMTP port 587
- SMTP encryption method STARTTLS

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?

---

<div class="post-metadata">

### Author: ![m.jason.miller](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@m.jason.miller](https://meta.discourse.org/u/m.jason.miller)
#### Post date: [August 9, 2021, 5:46pm UTC](https://meta.discourse.org/t/sending-emails-not-working/149883/15 "2021-08-09T17:46:49Z")

</div>

`DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none`

This solved _my_ issue thanks!
