Getting 'SMTPAuthenticationError' when using MailGun on Discourse? Check your SMTP server!
Sometimes you're just losing too much time on a very obvious solution. For me, it was using the right SMTP host on my Discourse installation...
After setting up Discourse on Digital Ocean through the marketplace, I couldn't finish the installation in my browser because I didn't receive the account confirmation email. It's a very common issue, and it can have a lot of reasons.
To find out what's going on, just SSH into your server and use these commands:
cd /var/discourse
./discourse-doctor
This will run some tests on your server. You'll also get the opportunity to send a test mail. Make sure to do this. After a couple of seconds, I got this error: SMTPAuthenticationError.
This error makes it seem like the username or password is wrong, but for me this wasn't the case. In fact, I was using the wrong Mailgun hostname.
See, in every tutorial (even in the Mailgun documentation), they're always using the hostname smtp.mailgun.org, but this is not always the case!
If you set up an EU domain in Mailgun, the SMTP hostname is smtp.eu.mailgun.org.
Just to make sure you're really using the right hostname, go to your Mailgun dashboard and click on the domain. Go to 'Overview' and then 'SMTP Credentials'. At the bottom of this page, you'll see the hostname you have to use.

Updating the hostname in the app.yml file (in /var/discourse/containers) was enough to fix the issue. After updating and saving the file, make sure to rebuild the app. This will take a while:
cd /var/discourse
./launcher rebuild app
If this doesn't fix the issue, make sure to follow the recommended troubleshooting steps.