# Emails not being sent from self-hosted Ghost instance

**URL:** <https://forum.ghost.org/t/emails-not-being-sent-from-self-hosted-ghost-instance/19784>\
**Category:** Developer help\
**Created:** [January 27, 2021, 2:43pm UTC](https://forum.ghost.org/t/emails-not-being-sent-from-self-hosted-ghost-instance/19784 "2021-01-27T14:43:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelSearson](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/michaelsearson/32/11389_2.png) [@MichaelSearson](https://forum.ghost.org/u/MichaelSearson)\
**Post date:** [January 27, 2021, 2:43pm UTC](https://forum.ghost.org/t/emails-not-being-sent-from-self-hosted-ghost-instance/19784/1 "2021-01-27T14:43:40Z")

</div>

- **What’s your URL**? [https://a7d47973106c4240b3baca79f3ef5a00.tk](https://a7d47973106c4240b3baca79f3ef5a00.tk)
- **What version of Ghost are you using?** 3.41.1
- **What version of Ghost CLI are you using?** 1.15.3

# Issue Summary

Emails are not being sent from Ghost.

 ![Screenshot 2021-01-26 at 18.09.28](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/f/fb0a8b5a6bf80b78f2d16aabba0200c96cc5d815.jpeg)

I think I’ve follow the documentation correctly, but I may have missed something. In addition to the SMTP details below I’ve also updated the `/settings/labs/members` Mailgun region, domain and API Key to match those provided in my MailGun Account.

# How was Ghost installed and configured?

Installed onto a Digital Ocean droplet using the [official one-click-deployment image](https://marketplace.digitalocean.com/apps/ghost?ipAddress=178.128.172.81#getting-started).

Of note the only configuration that has changed from the one-click-deployment was the `/var/www/ghost/config.production.json` file which has had the mail node updated as per the documation.

```json
"mail": {
    "transport": "SMTP",
    "options": {
    "service": "Mailgun",
    "host": "smtp.eu.mailgun.org",
    "port": 587,
    "secureConnection": true,
    "auth": {
        "user": "REDACTED",
        "pass": "REDACTED"
    }
  }
},

```

I’ve tried both the secure and non-secure examples shown in the docs and neither make any difference to the issue at hand.

# What Node version, database, OS & browser are you using?

Node: v12.18.0  
OS: Ubuntu  
Browser: Chrome

# What errors or information do you see in the console?

No related errors in the following log files:

- `/var/www/ghost/content/logs/https___a7d47973106c4240b3baca79f3ef5a00_tk_production.log`
- `/var/www/ghost/content/logs/https___a7d47973106c4240b3baca79f3ef5a00_tk_production.error.log`

# What steps could someone else take to reproduce the issue you’re having?

In theory, following through the instructions in the droplet image and configuring MailGun per the docs should re-create this issue each time.

Additional steps taken:

- Port 587 opened for MailGun
- Ghost restarted to ensure config changes are picked up
- Digital Ocean DNS configuration inline with the entries expected by MailGun

If I manually verify sending an email to MailGun via SMTP based on their own quickstart guide then it works as expected and I get the email through to my inbox:

```shell
./swaks --auth \
	--server smtp.eu.mailgun.org \
	--au postmaster@redacted \
	--ap REDACTED \
	--to EMAIL@EMAIL.COM \
	--h-Subject: "Testing" \
	--body 'Standard test to verify.'

```

The above command produces the following output (truncated for brevity):  
=== Trying smtp.eu.mailgun. org:25…  
=== Connected to smtp.eu.mailgun. org.  
 ← 220 Mailgun Influx ready

…

← 250 Great success  
 → QUIT  
 ← 221 See you later. Yours truly, Mailgun  
=== Connection closed with remote host.

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [January 27, 2021, 2:47pm UTC](https://forum.ghost.org/t/emails-not-being-sent-from-self-hosted-ghost-instance/19784/2 "2021-01-27T14:47:15Z")

</div>

@MichaelSearson the settings in `config.production.json` are for transactional email, you can set this up with Mailgun or any other email provider. Transactional emails are staff invites, member signups, etc.

Bulk email for newsletters is only available via Mailgun. You need to configure that by supplying an API Key in the members settings area.

Docs are here [https://ghost.org/docs/newsletters/](https://ghost.org/docs/newsletters/)

---

<div class="post-metadata">

**Author:** ![MichaelSearson](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/michaelsearson/32/11389_2.png) [@MichaelSearson](https://forum.ghost.org/u/MichaelSearson)\
**Post date:** [January 27, 2021, 3:26pm UTC](https://forum.ghost.org/t/emails-not-being-sent-from-self-hosted-ghost-instance/19784/3 "2021-01-27T15:26:49Z")

</div>

@Kevin thanks for the quick response and clarification around the settings!

As mentioned in the intial post I have configured the API settings in Ghost:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/7/7d9a18e4eed266d02049f960dcee60f0ec724914.jpeg)

And as per the hyperlinks in the screenshot I’ve copied over the mailgun domain and API Key. But that hasn’t made any difference.

Something that I have just noticed though. In MailGun’s examples of manually calling the API the URL structure is `https://api.eu.mailgun.net/v3/DOMAIN/messages`. In Ghost, I’ve just provided:

`https://api.eu.mailgun.net/v3/mg.a7d47973106c4240b3baca79f3ef5a00.tk`

Should I append the `/messages` route here as well? Or does Ghost take care of this for me?

If I manually call the API with the same credentials I get back a: `"message": "Queued. Thank you."` response so I must be doing something wrong with Ghost.

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [January 27, 2021, 3:58pm UTC](https://forum.ghost.org/t/emails-not-being-sent-from-self-hosted-ghost-instance/19784/4 "2021-01-27T15:58:27Z")

</div>

The Mailgun domain isn’t correct, it should only be a domain rather than a full URL. Try putting `mg.a7d47973106c4240b3baca79f3ef5a00.tk` in as the domain instead.

---

<div class="post-metadata">

**Author:** ![MichaelSearson](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/michaelsearson/32/11389_2.png) [@MichaelSearson](https://forum.ghost.org/u/MichaelSearson)\
**Post date:** [January 27, 2021, 4:10pm UTC](https://forum.ghost.org/t/emails-not-being-sent-from-self-hosted-ghost-instance/19784/5 "2021-01-27T16:10:34Z")

</div>

Aha! Gotcha - managed to overlook that! It’s all working as expected now. Thank you! 😃
