A user, superman, reports issues sending emails via a local SMTP server with Discourse, despite successful Telnet tests and Discourse doctor confirming SMTP connectivity. The root issue stems from a mismatch between the hostname in the SMTP certificate and the configured DISCOURSE_SMTP_ADDRESS — specifically, using mail.forum.domain.com instead of forum.domain.com. Falco clarifies the error refers to the SMTP service’s SSL certificate, not the site’s. superman resolves the certificate hostname mismatch by aligning the SMTP address with the server’s actual certificate, but still faces delivery failures. Later, superman confirms Discourse doctor reports success, yet emails never arrive. Syonyk advises checking the local SMTP server logs, where superman finds an Exim4 error: Sender verify failed, indicating the SMTP server rejected the sender address noreply@forum.domain.com due to sender verification. The discussion highlights confusion around Discourse’s SMTP configuration documentation and error messaging, with superman urging clearer guidance. While Discourse connects successfully, email delivery ultimately depends on correct SMTP server configuration, particularly sender verification and certificate alignment.
I have tested the SMTP server with Telnet:
Telnet connected to the SMTP server.
Telnet allowed me to authenticate into the SMTP server.
Telnet allowed me to successfully send an email using the SMTP server, and I used the exact same values in Telnet as are present in the /var/discourse/containers/app.yaml file.
Discourse doctor says that Discourse successfully connected to the SMTP server.
Discourse doctor says that Discourse failed to send the test email.
Therefore, Discourse has bugs preventing it from sending emails.
No. Because the SMTP server is working perfectly as already described and Discourse is properly installed and properly returns the screen that prompts the admin registration email. However, that email does not send.
I found an error in /var/discourse/shared/standalone/log/rails/production.log:
Rendering layouts/email_template.html.erb
Rendered layouts/email_template.html.erb (Duration: 0.1ms | Allocations: 32)
Delivered mail f915c15e-9c4d-4d4e-9527-81bc4984540c@forum.domain.com (63.7ms)
Job exception: hostname "mail.forum.domain.com" does not match the server certificate
This doesn’t sound like a bug in Discourse. It sounds like a problem in the host DNS resolver config or SSL certificate.
Since telnet doesn’t use SSL, I guess that’s why you found that to work. Under linux you may find you can get a bit further testing using OpenSSL to test the connection and examine certificates instead.
The https on the site is working because it shows the green padlock in the address bar. There is nothing wrong with the ssl certificate for the site. There is something wrong with the way Discourse detects the ssl certificate.
The SMTP service certificate is just the server’s ssl certificate, not the website’s ssl certificate. The server ssl certificate is correct, and working.
For setting up a local SMTP server on the same machine as the Discourse container, Discourse does not specify exactly what the correct values for the SMTP settings in app.yml should be. This leads to a great deal of confusion and errors.
In the app.yml settings, Discourse does not clearly specify what the DISCOURSE_SMTP_ADDRESS is supposed to be.
Discourse does not clearly specify what the “server certificate” is in this error statement that is present after sending the initial registration email fails. The error message is located in:
/discourse/shared/standalone/log/rails/production.log
“Job exception: hostname “mail.forum.domain.com” does not match the server certificate”.
However, in reality, the “server certificate” is simply the server’s ssl certificate.
Also, in the error message, Discourse incorrectly mentions “hostname”, when instead what is being referred to in reality is actually the DISCOURSE_SMTP_ADDRESS.
There was struggle because of Discourse’s ambiguity.
The solution was simply to set the server’s ssl certificate to the correct ssl certificate.
When the problem was posted to the Discourse forum, there were a lot of misleading and unclear answers.
Now Discourse doctor is saying the email was sent:
Sending mail to admin@email.com. . .
Testing sending to admin@email.com using forum.domain.com:587.
SMTP server connection successful.
Sending to admin@email.com. . .
Mail accepted by SMTP server.
However, there is no email in the receiving mailbox or spam.