# \[fixed\] Can not send the email

**URL:** https://meta.discourse.org/t/fixed-can-not-send-the-email/44190
**Category:** Self-hosting
**Created:** [May 13, 2016, 9:38am UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190 "2016-05-13T09:38:38Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![sandybeauty](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sandybeauty/32/121837_2.png) [@sandybeauty](https://meta.discourse.org/u/sandybeauty)
#### Post date: [May 13, 2016, 9:38am UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/1 "2016-05-13T09:38:38Z")

</div>

I use sparkpost mail to send email.  
tested with CURL can send email successfully.

but with discourse, always get this error:

Sent mail to [MYEMAIL@gmail.com](mailto:MYEMAIL@gmail.com) (695.6ms)  
Job exception: 500 5.5.2 unrecognized command

Sent mail to [MYEMAIL@gmail.com](mailto:MYEMAIL@gmail.com) (684.1ms)  
Job exception: 500 5.5.2 unrecognized command

I’ve already set app.yml SiteSetting.notification\_email options.

how can I fix it?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [May 13, 2016, 10:11am UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/2 "2016-05-13T10:11:57Z")

</div>

Can you show us your mail-related settings? (_makes sure you hide your credentials though_)

---

<div class="post-metadata">

### Author: ![sandybeauty](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sandybeauty/32/121837_2.png) [@sandybeauty](https://meta.discourse.org/u/sandybeauty)
#### Post date: [May 13, 2016, 12:25pm UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/3 "2016-05-13T12:25:34Z")

</div>

sure thing.

my config:

```yaml
DISCOURSE_SMTP_ADDRESS: smtp.sparkpostmail.com
#DISCOURSE_SMTP_PORT: 587 # (optional, default 587)
DISCOURSE_SMTP_USER_NAME: SMTP_Injection
DISCOURSE_SMTP_PASSWORD: API keys( working with curl test)
## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
#LETSENCRYPT_ACCOUNT_EMAIL: me@example.com

- exec: rails r "SiteSetting.notification_email='noreply@myownweb.com'"

```

thanks.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 13, 2016, 2:56pm UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/4 "2016-05-13T14:56:38Z")

</div>

You might uncomment the port setting. I had this problem when I moved over yesterday.

Please let me know if that fixes it.

---

<div class="post-metadata">

### Author: ![sandybeauty](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sandybeauty/32/121837_2.png) [@sandybeauty](https://meta.discourse.org/u/sandybeauty)
#### Post date: [May 13, 2016, 5:11pm UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/5 "2016-05-13T17:11:22Z")

</div>

hi ,Jay, indeed, that fixed the problem.

thanks. it’s a bug or something?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 13, 2016, 5:32pm UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/6 "2016-05-13T17:32:46Z")

</div>

I’m not sure. `standalone.yml` indicates that the default SMTP port is 587 and TLS defaults to true, but that seems not to be the case. @codinghorror?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 13, 2016, 7:18pm UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/7 "2016-05-13T19:18:42Z")

</div>

Not sure:

[https://www.fastmail.com/help/technical/ssltlsstarttls.html](https://www.fastmail.com/help/technical/ssltlsstarttls.html)

> SMTP uses port 25, but SSL/TLS encrypted SMTP uses port 465.
> 
> Many sites now disable plain IMAP (port 143) and plain POP (port 110) altogether so people must use an SSL/TLS encrypted connection. By disabling ports 143 and 110, this removes completely STARTTLS as even an option for IMAP/POP connections.
> 
> The one real exception to the above is SMTP. However that’s for a different reason again. Most email software used SMTP on port 25 to submit messages to the email server for onward transmission to the destination. However, SMTP was originally designed for transfer, not submission. So yet another port (587) was defined for message submission. Although port 587 doesn’t mandate requiring STARTTLS, the use of port 587 became popular around the same time as the realisation that SSL/TLS encryption of communications between clients and servers was an important security and privacy issue.
> 
> The result is that **in most cases, systems that offer message submission over port 587 require clients to use STARTLS to upgrade the connection and also require a username and password to authenticate.**
> 
> Currently, things seem relatively **randomly split between people using SMTP SSL/TLS encrypted over port 465, and people using SMTP with STARTTLS upgrading over port 587.**

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [May 13, 2016, 8:34pm UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/8 "2016-05-13T20:34:30Z")

</div>

> [@sandybeauty](#):
>
> t’s a bug or something?

> [@pfaffman](#):
>
> indicates that the default SMTP port is 587 and TLS defaults to true, but that seems not to be the case

> [@codinghorror](#):
>
> Not sure:

This right here seems to indicate to me that the default SMTP port “for Discourse” is `25:

> <https://github.com/discourse/discourse/blob/be3a5a56ccc284b352aa65080fc6b955f73cc72a/config/discourse_defaults.conf#L61-L62>

Not sure if changing this default is a good idea - you might find it breaks peoples installs.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 13, 2016, 9:02pm UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/9 "2016-05-13T21:02:22Z")

</div>

> [@DeanMarkTaylor](#):
>
> This right here seems to indicate to me that the default SMTP port “for Discourse” is `25:

[https://github.com/discourse/discourse\_docker/pull/256](https://github.com/discourse/discourse_docker/pull/256)

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [May 13, 2016, 9:05pm UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/10 "2016-05-13T21:05:30Z")

</div>

Looks like SMTP port is also missing from the setup script:

> <https://github.com/discourse/discourse_docker/blob/33c14f532ea2d7067514046c2fd3991a2f26e231/discourse-setup#L246>

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 13, 2016, 9:07pm UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/11 "2016-05-13T21:07:39Z")

</div>

I’m not completely sure this is a correct statement per our Docker image though. I need to check some things.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 16, 2016, 11:05am UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/12 "2016-05-16T11:05:14Z")

</div>

OK! I checked into this and it seems TLS can be used on, well, _any_ port really…

[https://www.fastmail.com/help/technical/ssltlsstarttls.html](https://www.fastmail.com/help/technical/ssltlsstarttls.html)

I went ahead and made the port selectable in the `./discourse-setup` script, with a value of 587 as the default that gets written to the `app.yml` file. That way we are no longer relying on implicit defaults, the `app.yml` will have the actual SMTP port specified.

(For the record, I’ve used the default – that is, leaving that line commented out – with mailgun and mandrill for ages and never had issues. But I think it’s best to be explicit here.)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 16, 2016, 11:06am UTC](https://meta.discourse.org/t/fixed-can-not-send-the-email/44190/13 "2016-05-16T11:06:30Z")

</div>


