Ghost unable to send emails

Hello,

I developed my own Ghost theme and am now trying to switch to Ghost 3.0 features. Specifically the members option. When trying to set up the email auth (Mailgun) I changed my production.config.json accordingly in Digital Ocean server console - I’m almost 100% sure I got it right. However, Ghost is still unable to send emails. I get this error:

Failed to send email. Reason: 139998923433792:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:…/deps/openssl/openssl/ssl/record/ssl3_record.c:332: .

Any help would be awesome. Thanks!

Martin

Hello Martin,

This error is linked with your SSL configuration.

You can find here an end-to-end how to configure Mailgun with Ghost if that can help you:
https://getsudocode.com/how-to-integrate-mailgun-email-to-ghost-blog/

If not resolved then please share your “mail” section in config.production.json file.

Hey,

thanks for answering. I followed the tutorial you recommended. For some reason the status of the DNS records at Mailgun is still as if they’re not set. What’s the deal with the SSL?

Here’s my mail section of the config.production.json:

Appreciate your help,
Martin

Hello Martin,

Thank you for your reply.

I will check your config but first please modify your screenshot and mask/remove your pass (and for security reason please change your passphrase in your mailgun account as soon as possible).

1 Like

Hello Martin,

Just checked your configuration and seems find the problem.

You have added this line:

"secureConnection": true,

But it’s not needed (only needed if you use a non secured SMTP port like default 25/tcp but in your case you used 587/tcp, submission port is already secured) then remove it and try a configuration like below:

  "mail": {
    "from": "'Martin Verbic' <me@mg.martinverbic.com>",
    "transport": "SMTP",
    "options": {
      "host": "smtp.eu.mailgun.org",
      "port": 587,
      "auth": {
        "user": "postmaster@mg.martinverbic.com",
        "pass": "<add your new passphrase here>"
      }
    }
  },

Keep me inform if your issue is fixed now.
If fixed then check “Solution” for this post that’s help others users with same issue.

4 Likes

Great, thank you for both pieces of advice…works like a charm.

Martin

1 Like

Hey, I think that then the official documentation should dis-clude that line!

Shall I open an issue @github?

1 Like

As far as I know, you can actually include this line but you have to change the port to 465.

If you have to ask…

The “Solution” did not work for me, and I think I have a pretty vanilla set up:

  • Fresh (first time) Ghost 4.16.0 installation on Ubuntu on a DigitalOcean Droplet using Ghost-CLI 1.17.3 and all the standard guides.
  • Created A records for @ and * of my custom domain to point at the Ghost server.
  • Ran ghost setup ssl soon after install and have been running https with the custom domain ever since.
  • Using default Casper and the default Portal with just the paid tiers turned off.

So nothing too exciting, but all working really nicely. Next step was to enable subscriptions, so:

"mail": {
    "from": "<FROM ADDR>",
    "transport": "SMTP",
    "options": {
      "service": "Mailgun",
      "host": "smtp.mailgun.org",
      "port": 587,
      "secureConnection": true,
      "auth": {
        "user": "<USERNAME>",
        "pass": "<PASSWORD>"
      }
    }

When I try to sign in to my own site, I get the dreaded “ssl3_get_record:wrong version number” error.

I tried all the suggestions in this thread to no avail. They made no difference.

This thread found a “solution” by removing the port and secure flags entirely, which seems ill-advised.

This thread simply suggests email doesn’t work in Ghost with SSL enabled, which is essentially the same worrying conclusion.

Finally, this thread suggested changing to port 465. After some research I see that it’s not recommended because 587 is well defined and uses the helpful “StartTLS” protocol to negotiate a secure connection. Port 487 is a bit less well-defined, but commonly uses “Implicit TLS”, which is essentially SSL straight out of the gate. So in summary, if port 587 doesn’t work and 465 does, it’s a fine fallback.

And whaddya know, port 587 doesn’t work in Ghost (maybe due to the nginx incompatibility) but Mailgun’s port 465 does! I simply changed the "port" value in my configuration to 465 and all is well.

Granted I’m not using the secure method (which I should probably update now thinking about it), however, I’m not having any issues with basic config found in config.production.json

"mail" : {

"transport" : “SMTP” ,

"options" : {

"service" : “Mailgun” ,

"auth" : {

"user" : “postmaster@mail-1.my-domian.com.au” ,

"pass" : "password"

1 Like

@EmpiricalEE Same thing here. It was working before I run an update, which I only did to get the patch that was being announced. I was on 4.14.x if I remember correctly. This was the setup that was working, and removing the "secure": true, doesn’t do anything. Found a reference in

     "mail": {
       "from": "'xxxxx' <xxxx@xxxx.xxx>",
       "transport": "SMTP",
       "options": {
         "host": "smtp.mandrillapp.com",
         "service": "Mandrill",
         "port": "587",
         "secure": true,
         "auth": {
           "user": "XXXX",
           "pass": "XXXX"
         }
       }
     },

Also found a mention in here to nodemailer version being an issue, but checking my installation, I can’t be sure that is what needs to be changed.

bitnami@ip-x.x.x.x : /opt/bitnami/ghost/current $ npm list nodemailer
ghost@4.16.0 /opt/bitnami/ghost/versions/4.16.0
└─┬ @tryghost/nodemailer@0.3.2
└── nodemailer@6.6.3

OK, tried "secure": false,. It says too many tries and that I need to wait for 22 minutes. I’ll report back. The setting it to false I got from this post in the forum.

Oh cripes. That was it. Turns out it was broken and being fixed right as I was trying to get it working for the first time!

As of 10 hours ago, all is revealed here.

In summary, yes, "secure" needs to be set to false, and the key recently changed names from "secureConnection". The incorrect key was being silently ignored, defaulting to true, and sending me on a wild goose chase!

I’ve set "port" back to 587, replaced "secureConnection": false with "secure": false and all is well.

1 Like

The "secure": false, didn’t work for me. I’m trying now to remove that line together with the port one, as suggested in one of the comments above the one you linked to. But “Too many attempts try again in an hour”. So I’ll wait…

I’m pretty sure the default uses non-secure SMTP (eg. port 25). Not the end of the world, but should be highly unnecessary if you’re using Mailgun and Ghost. What is the error you get?

OK, that didn’t work either. Just to be clear, first I had this, and after the update it stopped working:

     "mail": {
       "from": "'xxxxx' <xxxx@xxxx.xxx>",
       "transport": "SMTP",
       "options": {
         "host": "smtp.mandrillapp.com",
         "service": "Mandrill",
         "port": "587",
         "secure": true,
         "auth": {
           "user": "XXXX",
           "pass": "XXXX"
         }
       }
     },

I removed the "secure": true, line, but that didn’t help. After each update, I ran

sudo /opt/bitnami/ctlscript.sh restart

Next I added back "secure": false,, but that didn’t work either. And now I tried removing the "secure": false, and the "port": "587", lines, so that it looks like this:

     "mail": {
       "from": "'xxxxx' <xxxx@xxxx.xxx>",
       "transport": "SMTP",
       "options": {
         "host": "smtp.mandrillapp.com",
         "service": "Mandrill",
         "port": "587",
         "secure": true,
         "auth": {
           "user": "XXXX",
           "pass": "XXXX"
         }
       }
     },

and then I ran

sudo /opt/bitnami/ctlscript.sh restart

but no dice. Same error.

Want to run ghost doctor or ghost-cli but neither of them seem to work. I get an error.

bitnami@ip-172-26-4-25:/opt/bitnami/ghost$ ghost
-bash: ghost: command not found
bitnami@ip-172-26-4-25:/opt/bitnami/ghost$ ghost-cli
-bash: ghost-cli: command not found

Going to submit another case about that.

Sorry, it does look like this:

     "mail": {
       "from": "'xxxxx' <xxxx@xxxx.xxx>",
       "transport": "SMTP",
       "options": {
         "host": "smtp.mandrillapp.com",
         "service": "Mandrill",
         "auth": {
           "user": "XXXX",
           "pass": "XXXX"
         }
       }
     },

Sounds like something strange is going on there. What is the error message you get?

    "auth": {  
      "user": "postmaster@your_domain.com",  
      "pass": "your_password"  
    } 

The "user" and "pass", are those from the Mailgun account or Ghost admin account?