# Mail problem on discourse with reverse proxy

**URL:** https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563
**Category:** Self-hosting
**Created:** [February 8, 2022, 8:04pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563 "2022-02-08T20:04:01Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 8, 2022, 8:04pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/1 "2022-02-08T20:04:01Z")

</div>

I have configured in my app.yml the mail to be something like

```plaintext
  DISCOURSE_SMTP_ADDRESS: mail.mysecrect.tld
  DISCOURSE_SMTP_PORT: 465
  DISCOURSE_SMTP_USER_NAME: minegenix@mysecret.tld
  DISCOURSE_SMTP_PASSWORD: <secret>

```

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 8, 2022, 8:12pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/2 "2022-02-08T20:12:33Z")

</div>

Also found this on logs:

```plaintext
fail
Delivered mail 3ff63fed-4142-4042-ab33-29493b32b3a6@beta2.mysecret.tld (30001.9ms)
Job exception: execution expired

```

---

<div class="post-metadata">

### Author: ![IAmGav](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamgav/32/235598_2.png) [@IAmGav](https://meta.discourse.org/u/IAmGav)
#### Post date: [February 8, 2022, 8:15pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/3 "2022-02-08T20:15:27Z")

</div>

you might need to add this to your app.yml

` DISCOURSE_SMTP_ENABLE_START_TLS: false`

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 8, 2022, 8:17pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/4 "2022-02-08T20:17:12Z")

</div>

Okay, btw i use mailcow!

---

<div class="post-metadata">

### Author: ![rrit](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rrit](https://meta.discourse.org/u/rrit)
#### Post date: [February 8, 2022, 8:18pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/5 "2022-02-08T20:18:31Z")

</div>

Is the server running discourse **beta2**.mysecret.tld - and not mysecret.tld?

Give these options a try:

```yaml
DISCOURSE_SMTP_ADDRESS: 172.17.0.1 # use internal ip here - mail-server domain might not get resolved correctly
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: "YOUR-SMTP-USER-NAME"
DISCOURSE_SMTP_PASSWORD: "YOUR-SMTP-PASSWORD"
#DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
DISCOURSE_SMTP_DOMAIN: mysecret.tld

```

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 8, 2022, 8:19pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/6 "2022-02-08T20:19:40Z")

</div>

mysecret.tld is just placeholder hiding my real domain as i don’t want to reveal my forum address 🙂

---

<div class="post-metadata">

### Author: ![rrit](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rrit](https://meta.discourse.org/u/rrit)
#### Post date: [February 8, 2022, 8:27pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/7 "2022-02-08T20:27:52Z")

</div>

Are you sending mails with sender email like “…@ **beta2.** mysecret.tld” - but your mailcow account is for “…@mysecret.tld”?

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 8, 2022, 8:29pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/8 "2022-02-08T20:29:52Z")

</div>

no im sending emails from …@ mysecret.tld and the site is running at beta2.mysecret.tld

---

<div class="post-metadata">

### Author: ![IAmGav](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamgav/32/235598_2.png) [@IAmGav](https://meta.discourse.org/u/IAmGav)
#### Post date: [February 8, 2022, 8:35pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/9 "2022-02-08T20:35:24Z")

</div>

@Sprisa add the setting i posted and rebuild.

see if that helps.

@rrit you are missing the plot 🤦‍♂️

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 8, 2022, 8:35pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/10 "2022-02-08T20:35:39Z")

</div>

yeah im currently doing that

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 8, 2022, 8:36pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/11 "2022-02-08T20:36:02Z")

</div>

btw do i need to bootstrap everytime after rebuild?

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 8, 2022, 9:00pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/12 "2022-02-08T21:00:31Z")

</div>

Okay i added the settings, didn’t help.

---

<div class="post-metadata">

### Author: ![rrit](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rrit](https://meta.discourse.org/u/rrit)
#### Post date: [February 8, 2022, 9:21pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/13 "2022-02-08T21:21:09Z")

</div>

## How to debug issues with first connection to smtp server

### 1. Enter your container:

`./launcher enter app`

### 2. Check dns resolution for your smtp server name via `getent hosts`:

(`dig`, `nslookup`, `ping` etc. are not installed inside the container.)

```bash
getent hosts your.smtp.server

```

Result on success:

```bash
# IPv4
123.123.123.123 your.smtp.server

# IPv6
2001:db8:0:0:0:ff00:42:8329 your.smtp.server

```

### 3. Try to open a connection to your smtp server via `openssl`:

(`telnet`, `nc` etc. are not installed inside the container.)

Fiddle with some different settings until you succeed with a connection.

```bash
openssl s_client -connect your.smtp.server:465
openssl s_client -connect your.smtp.server:587 -starttls smtp

# IPv4
openssl s_client -connect 172.17.0.123:465
openssl s_client -connect 172.17.0.123:587 -starttls smtp

# IPv6
openssl s_client -6 -connect "[2001:db8:0:0:0:ff00:42:8329]:465"
openssl s_client -6 -connect "[2001:db8:0:0:0:ff00:42:8329]:587" -starttls smtp

```

See: [How to check SMTP connection → Step 3: Checking SMTP Connection Over TLS Using Openssl](https://netcorecloud.com/tutorials/smtp-connection-from-command-line/)

### 4. Use your found working connection settings with Discourse.

🚀

### Bonus: show Discourse IP from inside docker container

( `ifconfig` , `ip` etc. are not installed inside the container.)

```bash
hostname -I

```

Result like:

```bash
172.17.0.2

```

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 10, 2022, 7:46pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/14 "2022-02-10T19:46:08Z")

</div>

I can’t get connection with openssl, also i only get this: from the getent

```plaintext
2606:4700:3032::ac43:d2f1 mail.secret.tdl
2606:4700:3033::6815:4db8 mail.secret.tld

```

(secret.tld replacing my actual domain)

---

<div class="post-metadata">

### Author: ![rrit](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rrit](https://meta.discourse.org/u/rrit)
#### Post date: [February 10, 2022, 8:13pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/15 "2022-02-10T20:13:20Z")

</div>

> [@Sprisa](#):
>
> `2606:4700:3032::ac43:d2f1`

A shot in the dark: Is this a public IP? Is your mailcow configured to listen for smtp-connections on this public IP or only on an internal network?

Inside the Discourse container you can get your containers IP via:

```bash
hostname -I

```

Is your mailcow also on the same internal (docker-)network?

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 10, 2022, 8:15pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/16 "2022-02-10T20:15:06Z")

</div>

172.17.0.2 is the thing i get from hostname -I

---

<div class="post-metadata">

### Author: ![rrit](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rrit](https://meta.discourse.org/u/rrit)
#### Post date: [February 10, 2022, 8:16pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/17 "2022-02-10T20:16:35Z")

</div>

Can you get into your mailcow container and also get `hostname -I`? Are Mailcow and Discourse two seperate docker-containers on the **same** host?

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [February 10, 2022, 8:30pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/18 "2022-02-10T20:30:41Z")

</div>

how do i get into the mailcow container? there isn’t launcher script.

---

<div class="post-metadata">

### Author: ![rrit](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rrit](https://meta.discourse.org/u/rrit)
#### Post date: [February 10, 2022, 10:52pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/19 "2022-02-10T22:52:18Z")

</div>

I don’t know about mailcow either. Maybe better check back with the mailcow community: [https://community.mailcow.email/](https://community.mailcow.email/)

---

<div class="post-metadata">

### Author: ![Sprisa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sprisa/32/249086_2.png) [@Sprisa](https://meta.discourse.org/u/Sprisa)
#### Post date: [March 1, 2022, 3:04pm UTC](https://meta.discourse.org/t/mail-problem-on-discourse-with-reverse-proxy/217563/20 "2022-03-01T15:04:29Z")

</div>

What should i use to get mail systems, or what software can I setup on ubuntu that would work as mail service on my forums?
