Mail problem on discourse with reverse proxy

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

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

Also found this on logs:

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

you might need to add this to your app.yml

DISCOURSE_SMTP_ENABLE_START_TLS: false

Okay, btw i use mailcow!

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

Give these options a try:

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

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

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

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

@Sprisa add the setting i posted and rebuild.

see if that helps.

@rrit you are missing the plot :man_facepalming:

1 Like

yeah im currently doing that

1 Like

btw do i need to bootstrap everytime after rebuild?

Okay i added the settings, didn’t help.

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.)

getent hosts your.smtp.server

Result on success:

# 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.

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

4. Use your found working connection settings with Discourse.

:rocket:

Bonus: show Discourse IP from inside docker container

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

hostname -I

Result like:

172.17.0.2

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

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

(secret.tld replacing my actual domain)

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:

hostname -I

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

172.17.0.2 is the thing i get from hostname -I

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

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

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

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?