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:
Rendered layouts/email_template.html.erb (Duration: 0.1ms | Allocations: 32)
Delivered mail firstname.lastname@example.org (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.
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:
“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.