Fresh Discourse/Docker install wont send mails

Hi people,
I want to switch a long standing forum from phpBB3 to Discourse. I managed to setup the Docker, and am able to access the Initial Setup. Unfortunately there is no mail being sent, so i can’t finish the init.
I did some debugging and cant find the reason, so I am turning to you for help.

My setup is like this, I have setup apache2 as a reverseproxy to the docker, which works. My mailserver is a mailcow docker on the same machine. The mailserver is tested thoroughly and works fine on a daily basis through SMTP with STARTTLS on Port 587 and webmail.

the config in my app.yml looks like this:

  DISCOURSE_SMTP_ADDRESS: mail.example.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: discourse@example.com
  DISCOURSE_SMTP_PASSWORD: "password"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  #DISCOURSE_SMTP_DOMAIN: mail.example.com
  DISCOURSE_NOTIFICATION_EMAIL: discourse@example.com

when i run ./discourse-doctor i get:

==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [admin@example.com]: 
Sending mail to admin@example.com. . . 
Testing sending to admin@example.com using mail.example.com:587, username:discourse@example.com with plain auth.
 =======================================  
ERROR 
 ========================================
                                   UNEXPECTED ERROR

Cannot assign requested address - connect(2) for [correct ipv6]:587

====================================== 
SOLUTION 
=======================================
This is not a common error. No recommended solution exists!

Please report the exact error message above to https://meta.discourse.org/
(And a solution, if you find one!)

Being unable to find people with similar error messages on the web, I turned to this thread
I was easily able to connect to the mailserver with telnet from outside the container.

What I tried inside the container:

getent hosts mail.example.com

provided the correct IPv6 Adress
But then the errors started turning up:

openssl s_client -connect mail.example.com:587 -starttls smtp
140124593714496:error:0200206E:system library:connect:Connection timed out:../crypto/bio/b_sock2.c:110:
140124593714496:error:2008A067:BIO routines:BIO_connect:connect error:../crypto/bio/b_sock2.c:111:
connect:errno=110
openssl s_client -6 -connect "[correct IPv6]:587" -starttls smtp
139918557709632:error:02002063:system library:connect:Cannot assign requested address:../crypto/bio/b_sock2.c:110:
139918557709632:error:2008A067:BIO routines:BIO_connect:connect error:../crypto/bio/b_sock2.c:111:
connect:errno=99
 openssl s_client -connect smtp.gmail.com:587 -starttls smtp

works just fine
When I try the

openssl s_client -connect mail.example.com:587 -starttls smtp

from outside the container, It works also fine.
My mailcow/postfix logs show nothing…
I am stumped. Can you help me where to look next?

1 Like

See Troubleshoot email on a new Discourse install.

The issue is probably that your notification email address is not one that you have configured your mark server to send from.

But that doesn’t explain the “connection timed out” errors. That sounds like some docker network issue.

1 Like

thank you for your reply. I tried using the same adress in both fields, no change, same error.
Following the Troubleshooting thread:

What do the Discourse logs say?

`Job exception: Cannot assign requested address - connect(2) for [correct IPv6]:587

What do your email provider logs say?

No log entries show up relating to mails sent from discourse.

I then tried this Method https://www.saotn.org/test-smtp-authentication-starttls/ to see if I would be able to authenticate through openssl, and it works fine from the server, but not from inside the container, it produces the error I described in the first post.

How can I find out what is blocking the connection here?

1 Like

omfg it was so easy.
I just had to activate IPv6 in my Docker network, just the first three steps in this tutorial and it worked.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.