It appears to connect to the server and send a test email correctly if I do that manually:
> sudo ./launcher enter app
root@support-app:/var/www/discourse# openssl s_client -connect mail.xxxxxxxx.com:465
massive amount of junk
220 xxxxxxx.com Anti-spam GT for Coremail System (mispb-6da2110f-64b0-4d67-acf1-2d302bd594f9-xxxxxxx.com)
250-AUTH LOGIN PLAIN
AUTH PLAIN xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
235 Authentication successful
mail from: <firstname.lastname@example.org>
250 Mail OK
rcpt to: <email@example.com>
250 Mail OK
354 End data with <CR><LF>.<CR><LF>
250 Mail OK queued as AQAAfwBXr9nSGHdj3hEgAA--.7073S2
It’s likely that the outgoing port is being blocked by your hosting provider. If you’re using some service like mailgun (or most any other) then port 2525 should work. If it’s a mail server you run, then you can have it listen to another port (like 2525).
Or (probably hardest) you can open a ticket with whoever hosts your server and ask them to open the port.
Well, considering I can ./launcher enter app and then openssl connect to the mail server, login via SMTP and successfully sent an email from within the discourse container, I doubt that it is the port that doesn’t work…
I traced the code and it seems that EHLO wasn’t even reached. The SMTP server is connected but the SSL handshake seems to be missing, so the server quits and Discourse didn’t get any response, thus the error.
So, I suspected that port 465 support seems to have a bug (it defaults to SSL, but I don’t think Discourse recognizes that) so probably the SSL connection is never established.
Switching to port 25 seems to at least get rid of the error, although I am not receiving any sent email yet…
EDIT: I can confirm that port 25 works properly (as should 587 but unfortunately my smtp server doesn’t expose 587).
I didn’t get any emails before was due to the fact that the Discourse server IP address was temporarily blacklisted by the smtp server because of too many failed attempts.