# Ghost Labs: Mailgun domain and API

**URL:** <https://forum.ghost.org/t/ghost-labs-mailgun-domain-and-api/10979>\
**Category:** Memberships & subscriptions\
**Created:** [December 26, 2019, 2:13pm UTC](https://forum.ghost.org/t/ghost-labs-mailgun-domain-and-api/10979 "2019-12-26T14:13:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![inknos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/inknos/32/35582_2.png) [@inknos](https://forum.ghost.org/u/inknos)\
**Post date:** [December 26, 2019, 2:13pm UTC](https://forum.ghost.org/t/ghost-labs-mailgun-domain-and-api/10979/1 "2019-12-26T14:13:47Z")

</div>

Hello I am self hosting a ghost website.  
I am experiencing some problems using Ghost Labs Newsletter feature.  
When I set up my mailgun domain and API key the newsletter fails to send.

Here are the steps I took.

First: domain  
domain: [mail.libreadvice.org](http://mail.libreadvice.org)  
API key: private API key  
When I test the email from the post sidebar it says:  
“Error sending mail, please check your Mailgun configuration”

Second: full api EU link  
domain: [https://api.eu.mailgun.net/v3/mail.libreadvice.org](https://api.eu.mailgun.net/v3/mail.libreadvice.org)  
or domain: [https://api.eu.mailgun.net/v3/mail.libreadvice.org/messages](https://api.eu.mailgun.net/v3/mail.libreadvice.org/messages)  
From the post sdebar for test email it says “Email Sent” but the email does not really send and it does not reach the mailgun server either.

I tried using mailgun from command line with curl and it works so I am pretty confident that the url, API key and DNS settings are correct.

Here are my ghost configurations.

- **Version** 3.2.0
- **Environment** production
- **Database** mysql
- **Mail** Direct

Please, can you help me? Thanks a lot

---

<div class="post-metadata">

**Author:** ![f.ponomarev](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/f.ponomarev/32/7149_2.png) [@f.ponomarev](https://forum.ghost.org/u/f.ponomarev)\
**Post date:** [April 15, 2020, 4:24pm UTC](https://forum.ghost.org/t/ghost-labs-mailgun-domain-and-api/10979/2 "2020-04-15T16:24:07Z")

</div>

Same problem

---

<div class="post-metadata">

**Author:** ![fimo](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fimo/32/7363_2.png) [@fimo](https://forum.ghost.org/u/fimo)\
**Post date:** [April 16, 2020, 5:31pm UTC](https://forum.ghost.org/t/ghost-labs-mailgun-domain-and-api/10979/3 "2020-04-16T17:31:31Z")

</div>

This is what I am using in my config. See if it works for you (switching out your credentials). And change the HOST if you are not on EU

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

---

<div class="post-metadata">

**Author:** ![fimo](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fimo/32/7363_2.png) [@fimo](https://forum.ghost.org/u/fimo)\
**Post date:** [April 16, 2020, 5:32pm UTC](https://forum.ghost.org/t/ghost-labs-mailgun-domain-and-api/10979/4 "2020-04-16T17:32:03Z")

</div>

Also, REMEMBER TO RESTART Ghost for changes to take effect.

---

<div class="post-metadata">

**Author:** ![joncojonathan](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@joncojonathan](https://forum.ghost.org/u/joncojonathan)\
**Post date:** [April 23, 2020, 8:04pm UTC](https://forum.ghost.org/t/ghost-labs-mailgun-domain-and-api/10979/5 "2020-04-23T20:04:11Z")

</div>

Having the same problem with the newsletter feature. As @inknos says, I’m advised the test email has been sent but no email arrives and it doesn’t reach Mailgun either.

I have configured my production configuration to send all emails via Mailgun. Subscription sign up emails are coming through correctly (the headers indicate the email comes from Mailgun too).

Ghost has been restarted, and I’m currently configured with the full API link ([https://api.eu.mailgun.net/v3/blog.domain-redacted](https://api.eu.mailgun.net/v3/blog.domain-redacted)).

Any ideas please?

- Ghost-CLI version: 1.13.1
- Ghost version: 3.13.4
- Node version: 12.16.2
- Npm version: 6.14.4

---

<div class="post-metadata">

**Author:** ![joncojonathan](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@joncojonathan](https://forum.ghost.org/u/joncojonathan)\
**Post date:** [April 25, 2020, 12:38pm UTC](https://forum.ghost.org/t/ghost-labs-mailgun-domain-and-api/10979/6 "2020-04-25T12:38:29Z")

</div>

Hello,

I have now tested Mailgun using the command line on my server:

```bash
curl -s --user 'api:redacted-aaaaaaaa-aaaaaaaa' https://api.eu.mailgun.net/v3/blog.example.org.uk/messages -F from='Blog <noreply@blog.example.org.uk>' -F to=me@example.org.uk -F subject='Testing from SSH' -F text='Testing mailgun from Blog server.'

```

The email is correctly delivered.

The problem only seems to be when sending emails via the members feature. Specifically the “Email Newsletter \> send test email” function.

The Ghost log shows:

> {“name”:“Log”,“hostname”:“blog-server”,“pid”:12337,“level”:30,“req”:{“meta”:{“requestId”:“a5651543-7627-44f7-88e9-09a341881798”,“userId”:“5”},“url”:“/email\_preview/posts/redacted/”,“method”:“POST”,“originalUrl”:“/ghost/api/v3/admin/email\_preview/posts/redacted/”,“params”:{“id”:“redacted”},“headers”:{“host”:“[blog.example.org.uk](http://blog.example.org.uk)”,“x-forwarded-proto”:“https”,“x-real-ip”:“redacted”,“x-forwarded-for”:“redacted, redacted”,“connection”:“close”,“content-length”:“38”,“accept-encoding”:“gzip”,“cf-ray”:“1354198b9ebc6a83-LHR”,“cf-visitor”:“{"scheme":"https"}”,“user-agent”:“Mozilla/5.0 (X11; Linux x86\_64; rv:75.0) Gecko/20100101 Firefox/75.0”,“accept”:“application/json, text/javascript, _/_; q=0.01”,“accept-language”:“en-GB”,“referer”:“[https://blog.example.org.uk/ghost/",“content-type”:"application/json](https://blog.example.org.uk/ghost/%22,%22content-type%22:%22application/json); charset=UTF-8”,“x-ghost-version”:“3.13”,“app-pragma”:“no-cache”,“x-requested-with”:“XMLHttpRequest”,“origin”:“[https://blog.example.org.uk](https://blog.example.org.uk)”,“dnt”:“1”,“cookie”:“ **REDACTED** ”,“cf-request-id”:“redacted”,“cf-connecting-ip”:“redacted”,“cdn-loop”:“cloudflare”},“query”:{}},“res”:{“\_headers”:{“x-powered-by”:“Express”,“cache-control”:“no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0”,“access-control-allow-origin”:“[https://blog.example.org.uk](https://blog.example.org.uk)”,“vary”:“Origin, Accept-Encoding”,“content-type”:“application/json; charset=utf-8”,“content-length”:“2”,“etag”:“W/"2-vyHn7IuFo4RvsFtPoIWeCReyIC8"”},“statusCode”:200,“responseTime”:“218ms”},“msg”:“”,“time”:“2020-04-25T12:34:43.377Z”,“v”:0

Any assistance would be gratefully received.

Many thanks,

Jonathan

---

<div class="post-metadata">

**Author:** ![John](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/john/32/29288_2.png) [@John](https://forum.ghost.org/u/John)\
**Post date:** [June 3, 2020, 5:13am UTC](https://forum.ghost.org/t/ghost-labs-mailgun-domain-and-api/10979/8 "2020-06-03T05:13:47Z")

</div>

Closed on June 3, 2020, 5:13am UTC


