I think it’s failing before even attempting login.
To eliminate Discourse as a factor, try from the host AND from inside the container:
$ openssl s_client -connect smtp.mailgun.org:587 -starttls smtp
You should get a bunch of output and then be able to try to auth:
○ → openssl s_client -connect smtp.mailgun.org:587 -starttls smtp
Connecting to 34.160.63.108
CONNECTED(00000003)
…
SSL-Session:
…
---
read R BLOCK
EHLO localhost
250-2ed1d46f4d7dec773e2a97b59f3a3bf8a2d6db54f94eead5dcf49e3ea1caac18
250-AUTH PLAIN LOGIN
250-SIZE 52428800
250-8BITMIME
250-SMTPUTF8
250 PIPELINING
AUTH PLAIN bWljaGFlbABtaWNoYWVsAHBhc3N3b3Jk
501 Username used for auth is not valid email address
535 Authentication failed
closed
The strings you would type are:
EHLO localhost
AUTH PLAIN bWljaGFlbABtaWNoYWVsAHBhc3N3b3Jk
(that string is the creds michael/password so it obviously won’t work, but you can see this post to learn how to construct the string for your actual credentials if you want to try by hand)
Hopefully seeing firsthand what works and what fails will help.
You might also want to try using swaks if it’s available - it’s probably an OS package you can install.
It’s a bit easier and you can e.g.:
swaks --to frodo@shire.net --from bilbo@shire.net --auth PLAIN --auth-user bilbo --auth-password ring --server smtp.mailgun.org:587 --tls
except you can use your real credentials.
The output of that might also help reveal the problem.