Hostname does not match the server certificate - none of the other threads provide solutions to this

AI-generated summary

Codes09 is struggling with a persistent SMTP error in Discourse: “Hostname does not match the server certificate,” despite having valid Let’s Encrypt certificates, SPF, and DKIM records for both their domain and DirectAdmin mail server. Their setup involves sending mail from a shared mail server where the hostname differs from the sending domain — a common scenario for multi-domain setups. They’ve tried disabling SSL verification via DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none in app.yml, but it hasn’t resolved the issue, possibly because they didn’t rebuild the container after the change. Simon_Manning asks for logs to pinpoint the error and clarifies that the sending domain doesn’t affect SSL — only the hostname in DISCOURSE_SMTP_ADDRESS matters. He warns that disabling SSL verification is a security risk unless the mail server is on the same machine or trusted network. Codes09’s frustration stems from months of failed attempts to get a private mail server working for their small, private tech community, as transactional email services are inaccessible to them. The core issue appears to be either a misconfigured hostname in SMTP settings, missing container rebuild, or a deeper certificate mismatch not addressed by disabling verification. No existing forum threads offer a working solution, making this a unique and unresolved configuration challenge.

Searching threads in this Forum came up blank. It’s seems this is the issue everyone is asking about but there are little solutions.

I’ve got working credentials and a working DirectAdmin mail server that I share among several domains I run. So naturally the hostname does not equal the sending domain name.

I’ve got Lets-encrypt certificates setup for the domain name and mail-server. SPF and Dkim records are valid as well.

However Discourse keeps bumping into this issue and won’t accept the mail server.One of the other threads suggested adding to app.yml:

DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

This too has not worked.

My Discourse is a small private community for a group of tech colleagues. As a result I’m having a hard time getting any participation from transactional mail services. So I need a private mail server to work.

I’ve tried several ways of solving this for 4months. Setting up a service should not be this hard.

Do you have any logs you can provide to show the actual error you’re seeing and where it’s happening?

It sounds like you’re talking about Discourse sending emails via your DirectAdmin mail server. If this is the case, the sending domain has no bearing on SSL, the DirectAdmin server would just need a valid certificate for the domain used for DISCOURSE_SMTP_ADDRESS in your Discourse app.yml file.

When you added DISCOURSE_SMTP_OPENSSL_VERIFY_MODE to app.yml, did you also rebuild the container? Any change to app.yml will require the container to be rebuilt before it takes effect. Note however that even if that option does work, disabling OpenSSL verification is a security risk and should not be used unless the mail server is on the same machine or at least within the same closed network.