# Mailgun integration not working

**URL:** <https://forum.ghost.org/t/mailgun-integration-not-working/14446>\
**Category:** Integrations & API\
**Created:** [May 17, 2020, 11:50pm UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446 "2020-05-17T23:50:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tobetanium](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/tobetanium/32/7912_2.png) [@Tobetanium](https://forum.ghost.org/u/Tobetanium)\
**Post date:** [May 17, 2020, 11:50pm UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446/1 "2020-05-17T23:50:23Z")

</div>

I integrated Mailgun (as far as filling out all the settings and adding the mail settings to the config file as below:

“mail”: {  
“transport”: “SMTP”,  
“options”: {  
“service”: “Mailgun”,  
“host”: “[smtp.mailgun.org](http://smtp.mailgun.org)”,  
“port”: 465,  
“secureConnection”: true,  
“auth”: {  
“user”: “[postmaster@mg.mydomain.com](mailto:postmaster@mg.mydomain.com)”,  
“pass”: “blahblahblahnotmyactualpass”  
}  
}  
},

(also changed the url at the top of the config file from http to https - not sure if that’s relevant)  
…but when I try sending a test mail in Labs, I get the following message:

Failed to send email. Reason: Client network socket disconnected before secure TLS connection was established.

Can anyone help me solve this mystery please?

---

<div class="post-metadata">

**Author:** ![DavidDarnes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/daviddarnes/32/3533_2.png) [@DavidDarnes](https://forum.ghost.org/u/DavidDarnes)\
**Post date:** [May 19, 2020, 2:43pm UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446/2 "2020-05-19T14:43:32Z")

</div>

Kinda guessing here but have you set up a SSL certificate for your site? Ghost has a CLI helper to do this:

> **[Official Ghost + Let's Encrypt Integration](https://ghost.org/integrations/lets-encrypt/)**
>
> Ensure your publication is secure with free SSL via a full integration with Let's Encrypt. Find out how to provision a new SSL certificate in Ghost!

---

<div class="post-metadata">

**Author:** ![Tobetanium](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/tobetanium/32/7912_2.png) [@Tobetanium](https://forum.ghost.org/u/Tobetanium)\
**Post date:** [May 19, 2020, 8:22pm UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446/3 "2020-05-19T20:22:01Z")

</div>

Yes, I’ve got a Let’s Encrypt SSL on my domain. I’m not sure what else I can try at the moment. Here’s my config file with my Mailgun settings plugged in:

 ![ConfigFileMailgun](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/3/3ced306e211145c831391ae57ef6113f3486287b.png)

Do I actually need the smtp set up when I have my Mailgun domain and api key plugged into Ghost Labs?

---

<div class="post-metadata">

**Author:** ![Tobetanium](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/tobetanium/32/7912_2.png) [@Tobetanium](https://forum.ghost.org/u/Tobetanium)\
**Post date:** [May 20, 2020, 9:51am UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446/4 "2020-05-20T09:51:23Z")

</div>

In Labs when I try to send a test email I get the following error message in the orange bar:

Failed to send email. Reason: 140204983400320:error:1408F10B:SSL routines:ssl3\_get\_record:wrong version number:…/deps/openssl/openssl/ssl/record/ssl3\_record.c:252: .

In the Mailgun domain field in Labs, what should the domain look like?:

1. [https://api.mailgun.net/v3/mg.mydomain.com](https://api.mailgun.net/v3/mg.mydomain.com) or
2. [mg.mydomain.com](http://mg.mydomain.com)

I also get a “Please enter a valid email address” error when I enter any email address in the sign up or newsletter fields. None of the forum fixes I’ve tried seem to work so far.

---

<div class="post-metadata">

**Author:** ![DavidDarnes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/daviddarnes/32/3533_2.png) [@DavidDarnes](https://forum.ghost.org/u/DavidDarnes)\
**Post date:** [May 20, 2020, 12:21pm UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446/5 "2020-05-20T12:21:12Z")

</div>

I’ve seen some people get stuck from missing out the `host` being `smtp.eu.mailgun.org`?

> **[Configuration - Adapt your publication to suit your needs](https://ghost.org/docs/config/)**
>
> Find out how to configure your Ghost publication or override Ghost's default behaviour with robust config options, including mail, storage, scheduling and more!

---

<div class="post-metadata">

**Author:** ![Tobetanium](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/tobetanium/32/7912_2.png) [@Tobetanium](https://forum.ghost.org/u/Tobetanium)\
**Post date:** [May 22, 2020, 11:13am UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446/6 "2020-05-22T11:13:07Z")

</div>

I checked the other day and am using the US server so I used [smtp.mail.org](http://smtp.mail.org).

Just writing up a new post with where I’m at now.

---

<div class="post-metadata">

**Author:** ![Tobetanium](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/tobetanium/32/7912_2.png) [@Tobetanium](https://forum.ghost.org/u/Tobetanium)\
**Post date:** [May 22, 2020, 11:54am UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446/7 "2020-05-22T11:54:17Z")

</div>

I managed to get the emails working! Well, mostly. Here’s a rundown of what I changed, together with screenshots that I hope might help someone in the future.

I posted my config file that didn’t work upthread. I tried removing the following two lines of code:

“port”: 587,  
“secure”: false,

…and the emails started sending/working. Here’s the config file with the settings that worked for me:

 ![ConfigthatWorks](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/b9c9d3fe7d6e393aae5496241b2be6d04a4b64be.png)

I then tried sending a test email in the Labs section of Ghost:

 ![LabsTestEmailButton](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/e/e7f31d5945efd6e227f02ce968a34c256f9842b9.png)

Which resulted in this:

 ![LabsTestMailSent](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/d/d2c33d50d44f81391eec943b9552d97fc7eafc3e.png)

I checked my inbox and I had received the test email from Ghost:

 ![TestEmailReceivedMainInbox](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/2/22202c2c7d582cbb4bd0403bce4b5df8c522074f.png)

Next I signed up to become a member:

 ![NewsletterSignupSent](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/0/0335c670738818d998ab66b0305ee681d48489d4.png)

Email with link to confirm subscription arrives, although it goes to promo tab in Gmail:

 ![NLConfirmArrivesPromoTab](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/c/c3b3b5e98728ff7867c676579f2d283cc40958e6.png)

 ![ConfirmSubGoestoPromoTab](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/a/ae699fbe10addb734352ca098c4e3ca93161c0cd.png)

Looking in the Members tab of my Ghost site I see:

 ![NewSubinMembers](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/b78bd5e5ef3e79288c6ebb8cc9d6ed3db52a982c.png)

 ![MemberAccountPage](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/8/8548cea12de7ad501ce403722ff865f4e153b947.png)

I then tested signing out of my members account, clicking signin, clicking on secure link which arrived in inbox, and returning to my site:

 ![WelcomeBackSignedIn](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/8/8293ca09aba55ab47e53ee5111e84eb8c752c4f4.png)

So that’s all the successes so far.

Where I’m stuck now is when I create a post to send to members, I get the message that the post has been published and sent to X members, but the email never arrives to members inboxes.

Anyway, I hope this helps someone. I still have a way to go I guess in figuring this out, but I know how much time I spent trawling other threads trying to find anything new to change and test and get things working.

---

<div class="post-metadata">

**Author:** ![denvergeeks](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/denvergeeks/32/7401_2.png) [@denvergeeks](https://forum.ghost.org/u/denvergeeks)\
**Post date:** [May 22, 2020, 4:54pm UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446/8 "2020-05-22T16:54:40Z")

</div>

@Tobetanium Thank you for sharing your process on the forum – please do continue to post through your final resolution and what you learned.

I also use Mailgun, so it will be very helpful for me.

---

<div class="post-metadata">

**Author:** ![DavidDarnes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/daviddarnes/32/3533_2.png) [@DavidDarnes](https://forum.ghost.org/u/DavidDarnes)\
**Post date:** [June 3, 2020, 3:38pm UTC](https://forum.ghost.org/t/mailgun-integration-not-working/14446/9 "2020-06-03T15:38:02Z")

</div>

Pleased you got most of it working, and that you shared it here 😄. The sending of posts to members is something that specifically Mailgun is used for, so it can handle the possible large bulk of emails being sent at a single time. Keep us updated and I’ll try to help out 👍
