# Email does not work; Net::SMTPAuthenticationError

**URL:** <https://meta.discourse.org/t/email-does-not-work-net-smtpauthenticationerror/317828>\
**Category:** Self-hosting\
**Tags:** email\
**Created:** [July 23, 2024, 12:48pm UTC](https://meta.discourse.org/t/email-does-not-work-net-smtpauthenticationerror/317828 "2024-07-23T12:48:44Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![wal](https://avatars.discourse-cdn.com/v4/letter/w/d6d6ee/32.png) [@wal](https://meta.discourse.org/u/wal)\
**Post date:** [July 23, 2024, 12:48pm UTC](https://meta.discourse.org/t/email-does-not-work-net-smtpauthenticationerror/317828/1 "2024-07-23T12:48:44Z")

</div>

I am hosting the Discourse server on DigitalOcean, domain from PorkBun, mail server with MailGun.

My MailGun account is activated and the domain (`discourse.mydomain.com`) is verified for use with `mg.mydomain.com`. All the DNS TXT records are in place.

I have done every single troubleshooting step in the thread here multiple time; [Troubleshoot email on a new Discourse install](https://meta.discourse.org/t/troubleshoot-email-on-a-new-discourse-install/16326)

I can enter `telnet` on the host and send email manually without issue ([https://serverfault.com/questions/49935/easiest-way-to-send-a-test-email-from-a-server-to-test-settings](https://serverfault.com/questions/49935/easiest-way-to-send-a-test-email-from-a-server-to-test-settings))

The `app.yml` has these contents

```yaml
  DISCOURSE_DEVELOPER_EMAILS: 'myemail@gmail.com'
  DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: mail
  DISCOURSE_SMTP_PASSWORD: "12345678901234567890"
  DISCOURSE_SMTP_DOMAIN: mg.mydomain.com
  DISCOURSE_NOTIFICATION_EMAIL: admin@mg.mydomain.com

```

When I try to run `discourse-doctor` or if I run `./launcher enter app` then run `rake 'emails:test[mail@mg.mydomain.com]'` I get the following error

```plaintext
======================================== ERROR ========================================
                                    UNEXPECTED ERROR

Net::SMTPAuthenticationError

====================================== SOLUTION =======================================
This is not a common error. No recommended solution exists!

Please report the exact error message above to https://meta.discourse.org/
(And a solution, if you find one!)
=======================================================================================

```

Something is broken on Discourse, because I have no trouble sending the mail manually. I have been searching Google and the forums here for many hours, no solutions yet. Any ideas?

---

_[View the full topic](https://meta.discourse.org/t/email-does-not-work-net-smtpauthenticationerror/317828)._
