Before I saw this I was going to recommend this change.
Port 465 is SMTP-over-SSL, which is deprecated
Port 587 is the MSA port (mail submission agent) on which STARTTLS (upgrade from a plaintext to a TLS connection) is typically supported
When you had 465 in the configuration, Discourse was trying to talk plaintext to an SSL port.