# Can't send email with certificate issue

**URL:** https://meta.discourse.org/t/cant-send-email-with-certificate-issue/113207
**Category:** Self-hosting
**Created:** [April 2, 2019, 8:35am UTC](https://meta.discourse.org/t/cant-send-email-with-certificate-issue/113207 "2019-04-02T08:35:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kyu](https://avatars.discourse-cdn.com/v4/letter/k/b3f665/32.png) [@kyu](https://meta.discourse.org/u/kyu)
#### Post date: [April 2, 2019, 8:35am UTC](https://meta.discourse.org/t/cant-send-email-with-certificate-issue/113207/1 "2019-04-02T08:35:49Z")

</div>

Tried to setup discourse and have issue with email setup.  
I have [mail.mydomain.com](http://mail.mydomain.com) connected to a mail server configured in NAS with host name  
[smtp.myquickid.synology.me](http://smtp.myquickid.synology.me)  
I can send/receive mail [whatever@domain.com](mailto:whatever@domain.com) from thunderbird

So I setup discourse app.yml as below

```yaml
  DISCOURSE_SMTP_ADDRESS: smtp.myquickid.synology.me
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: admin@mydomain.com
  DISCOURSE_SMTP_PASSWORD: "plainpassword!"
  DISCOURSE_SMTP_ENABLE_START_TLS: false # (optional, default true)
  #DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

```

Since I have issue with certificate, I set TLS to false however mail can’t be sent

```plaintext
$ tail /var/discourse/shared/standalone/log/rails/production.log shows
....
Sent mail to admin@mydomain.com (30.1ms)
Job exception: 530 5.7.0 Must issue a STARTTLS command first

```

I think this is caused by setting TLS to false.  
Also setting the port 25 gives same thing.

I did check both

```plaintext
$ telnet smtp.myquickid.synology.me 25
$ telnet smtp.myquickid.synology.me 587

```

all work fine.

How to solve this problem?

---

<div class="post-metadata">

### Author: ![kyu](https://avatars.discourse-cdn.com/v4/letter/k/b3f665/32.png) [@kyu](https://meta.discourse.org/u/kyu)
#### Post date: [April 2, 2019, 9:15am UTC](https://meta.discourse.org/t/cant-send-email-with-certificate-issue/113207/2 "2019-04-02T09:15:57Z")

</div>

I managed to figure this out myself.  
Settings below works for my situation.

```yaml
  DISCOURSE_SMTP_ADDRESS: smtp.myquickid.synology.me
  DISCOURSE_SMTP_PORT: 25
  #DISCOURSE_SMTP_USER_NAME: admin@mydomain.com
  #DISCOURSE_SMTP_PASSWORD: "plainpass"
  DISCOURSE_SMTP_ENABLE_START_TLS: false # (optional, default true)
  #DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
  #DISCOURSE_SMTP_AUTHENTICATION: none
  DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

```

Ignoring user name and password is weird though.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [April 2, 2019, 1:55pm UTC](https://meta.discourse.org/t/cant-send-email-with-certificate-issue/113207/3 "2019-04-02T13:55:33Z")

</div>

> [@kyu](#):
>
> ```plaintext
> Job exception: 530 5.7.0 Must issue a STARTTLS command first
> 
> ```

This isn’t a certificate problem, this is the _other_ end telling you “I won’t accept credentials over a plaintext connection, you need to use STARTTLS to connect to me and authenticate so you can send mail.”

You should enable `STARTTLS` and either set up Let’s Encrypt for SMTP, or just disable certificate verification.

> [@kyu](#):
>
> Settings below works for my situation.
> 
> ```plaintext
> DISCOURSE_SMTP_PORT: 25
> 
> ```

That’s because now you’re sending to the SMTP port which is used for mail _delivery_ not _submission_. Unless that mailserver is configured to relay mail for your IP, it will _only_ accept mail for the email domains for which it is configured to accept mail.
