Hostname doesn't match server certificate (Let's Encrypt)

AI-generated summary

The user dun is experiencing an issue with Discourse where the activation email is not being sent due to a “hostname doesn’t match server certificate” error. They have a setup where both the mailserver (docker-mailserver) and Discourse are running on the same machine, using a self-ordered VPS and a Namecheap domain.

dun has verified that the mailserver is working correctly, with DKIM and SPF records set up, and has successfully sent and received emails using Thunderbird.

The issue is likely due to the mailserver using a different certificate than the one generated by Let’s Encrypt for Discourse. dun believes that using the same certificate for both containers would resolve the issue, but is unsure of how to achieve this.

pfaffman suggests that this is a mail server certificate issue and recommends using a mail service like Mailgun or seeking help from the docker-mailserver community.

Hi, I have a problem with receiving the activation mail after Discourse was installed.

My process:

I currently have no mailserver so I wanted to run mailserver and Discourse on the same machine. I decided to use docker-mailserver. I’ve ordered a VPS from a German provider and I’m using a Namecheap domain I wasn’t using anymore.
Because I don’t want this domain to be public I switched it with “domain. com” below. I hope that’s ok.

  1. Mailserver: I installed the mailserver, created some mail addresses with setup.sh, generated dkim and created a TXT record for it at my DNS provider. I tested the addresses with Thunderbird and I was able to send and receive mails without any problem. Telnet also returns 220 so everything seems to be ok.
    Here is screenshot of the DNS records:


    SSL-Tools result:
    Imgur: The magic of the Internet

  2. Discourse I installed Discourse by following the Beginner Docker install guide .
    I ran discourse-setup and entered the following data:

    Hostname      : domain.com
    Email         : dun@domain.com
    SMTP address  : domain.com
    SMTP port     : 587
    SMTP username : discourse@domain.com
    SMTP password : ABCDEFG123
    LETSENCRYPT_ACCOUNT_EMAIL: tls@domain.com
    

Then I proceeded to send the activation link to dun@domain. com but it never arrived.

dun@server:~$ tail /var/discourse/shared/standalone/log/rails/production.log 

Sent mail to dun@domain.com (69.5ms)
Job exception: hostname "domain.com" does not match the server certificate

Sent mail to dun@domain.com (61.3ms)
Job exception: hostname "domain.com" does not match the server certificate

Sent mail to dun@domain.com (22.8ms)
Job exception: hostname "domain.com" does not match the server certificate

I don’t fully understand what this means because this is the first time I’m configuring TLS. I guess it’s because I’m using a different certificate for the mailserver. How could I use the same certificate for both containers?

This is an issue with the mail server certificate. You can probably get one with Let’s Encrypt, but it’s not a problem with Discourse, so ask for help from the docker-mailserver people. If you want people to receive your mail and not to spend a long long time getting your mail server trusted, you’ll be better off using a mail service like Mailgun.

Thanks for your reply.
I guess I understand it a little bit better now. With my configuration Discourse already created the LE certificate while installing. The next step to get this running would be using that certificate on my mailserver which seems to be kinda tricky. At least I didn’t found anyone mentioning a process like this. I searched for pem files in the Docker VM and found them in /etc/ssl/certs and in ruby-folders under /usr/local/lib and /var/www/discourse/vendor. But I don’t really know if I could just copy them to the virtual machine that’s running the mailserver.

So the conclusion is, that it’s not possible to make this setup run without having more knowledge about TLS.