Members and Subscribing still wont work even on Ghost v4 (401 Error)

I have been developing Ghost Themes for a while now, and since v3 implementing membership or simply adding a subscribe button has been proven impossible.

I do everything as the documentation says, I can even copy the code on the documentation page and paste it on my theme and it won’t work. It doesn’t work on localhost nor the production online. It didn’t work on v3 and with v4 I hoped this could change but it still a difficult process.

Can someone help me with this? I have searched everywhere and nothing could put me in the right direction.

The only hint I have is this console error
image

Thanks for your attention

1 Like

The “401 Unauthenticated” is expected, it’s the API saying there’s no member logged in.

Could you explain what exactly isn’t working? There’s nothing in your topic that explains what you are expecting and how what you are seeing doesn’t match

I also just upgraded to v4 and can’t seem to get subscriptions to work despite mailgun saying I’m good to go.

An issue seems to be that gmail addresses aren’t recognized as valid
Image

Despite definitely being valid.

Oddly enough, my gsuite email does work (albiet by landing in my SPAM inbox)
image

Here’s how things look in my admin tab:

I’m using Namecheap for the domain and am self hosting ghost. Why do regular gmail addresses not work here? It looks like this may be a recurring issue?

Okay, so there are two issues here.

  1. Upgrading from Ghost v3 to v4 with mailgun properly set up does not recognize gmail domains as valid email addresses for subscriptions (note I did not previously have subscriptions set up).
  2. Confirmation requests sent to email addresses that are recognized as valid are sent to the SPAM folder.

I can confirm that my mailgun account is set up correctly because when I CURL the API, I am able to send an email to myself that does not get flagged as SPAM.

curl -s --user 'api:<MYKEY>' \
	https://api.mailgun.net/v3/mydomain/messages \
	-F from='Excited User <test_author@mydomain>' \
	-F to=testemail@otherdomain\
	-F subject='Hello' \
	-F text='Testing some Mailgun awesomeness!'

So our second issue above uniquely arises from the interaction between Ghost and Mailgun.

I still don’t have any clues on why the first issue is happening. Any suggested work arounds here?

Alrighty, so after burning 4 hours on this I finally managed to get subscriptions working. For those reading in the future - what I am about to say applies to self hosted ghost installations on Digital Ocean… perhaps specifically after migrating from v3 to v4. This may apply more generally.

Set up mailgun

After mailgun confirms that you set up your domain correctly then you wont need to do any further configuration on their service. You’ll know you’re good to go once you get an email like this:

Set up Ghost to work with mailgun

At this point you will have a strong temptation to configure the API credentials for mailgun under the subscriptions tab. Go ahead and do that. At this point you will believe that you’re integration is complete but you’re wrong (as verified by @Sarah_Hein ).

Update config.production.json file

Log in to your hosted ghost server.

To quote @ravingDIODE instruction’s to locate the production file… you should:

  1. Navigate to the ghost installation folder: “cd /var/www/ghost”

  2. Then, just to make sure, list the folder contents: “ls”

  3. You should see the following:
    image

  4. To edit the file type in: "sudo nano config.production.json. If the file does not exist, then first run ghost config to create it.

  5. Set the mail configuration as follows:

  6. Replace the user and password field with the ones provided in your mailgun settings (to get your password just click “Reset Password”):

  7. At this point the "secureConnection" key is currently set to true. Taking a tip from @joncojonathan , change the "secureConnection" key to false. (Having it true didn’t work for me).

  8. Then Hit control-s to save and then control-x to quit nano.

Finally, now that you’re back on the command line, run ghost restart to put your changes into effect.

Thank you

Just wanted to give a big shout out to the ghost developers for making Ghost an amazing - if not the most amazing - blogging platform on the Internet. And I am also very thankful to the ghost user community who took time to document parts of their solutions without which I would not have been able to get this feature working. Thank you all!!

1 Like