Mailgun integration not working

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”,
“port”: 465,
“secureConnection”: true,
“auth”: {
“user”: “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?

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

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:

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

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 or
  2. 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.

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

I checked the other day and am using the US server so I used smtp.mail.org.

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

1 Like

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:

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

Which resulted in this:

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

Next I signed up to become a member:

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

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

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

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.

2 Likes

@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.

Pleased you got most of it working, and that you shared it here :smile:. 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 :+1:

1 Like