Ghost won't send registration e-mails via Mailgun

I’m currently running Ghost v4.16 in Docker. I set up a Mailgun account last night and was able to successfully send a test post e-mail (with the contents of a post).

However, I’ve now discovered that when someone tries to subscribe to my blog via the “Subscribe” button, an error is thrown:

Failed to load resource /blog/members/api/send-magic-link/
{"errors":[{"message":"Resource not found","context":null,"type":"NotFoundError","details":null,"property":null,"help":null,"code":null,"id":"af8j2de0-2155-16ec-9y1c-25f30e45586e"}]}

I’ve found several recent threads on similar issues, all which point to a solution involving editing some lines in the config.production.json file.

However, I do not have anything other than my database configuration in my config.production.json file.

I thought I could try to add my mail configuration, but the only example I could find in the Ghost documentation is how to set it up for SMTP, which my Ghost instance is telling me not to use (hence why I’ve configured Mailgun).

Does anyone know how I can resolve this issue?

I have the same problem. Running Ghost v4.16 on DO Droplet, config.production.json is configured
right, but it does not work. Console gives same error.

Why do you think you can use Mailgun without SMTP? As far as I know, the SMTP and API interfaces are used, with some types of emails sent by one and some sent by the other. The API interface is configured in Settings → Email newsletter → Email newsletter settings, so maybe that’s why your test email worked.

The SMTP interface, on the other hand, needs to be configured in the config file. Here’s a handy alternative guide that gets to the same result:

Thanks for the response. I’ll try manually configuring the e-mail in the meantime, but I was avoiding SMTP because the Ghost docs literally say it shouldn’t be used:

Ghost has the ability to deliver posts as email newsletters natively. A bulk-mail provider is required to use this feature and SMTP cannot be used — read more about mail config.

I assumed configuring Mailgan and providing Ghost w/ the API was utilizing something other than SMTP given the heavy messaging against it.

Right. SMTP is not used for bulk-mail like newsletters. But you’re talking about the subscription magic link email. That’s a single email - a so called “Transactional” email. You still need some way to send those. SMTP is fine (and generally more reliable than the default “Direct” method) for that.

@EmpiricalEE is correct. The important line to note in the docs is this (emphasis mine)

Why can’t I just use SMTP mail config to send email newsletters with Ghost?

Thanks all for the responses. I’ve noted the recommendations and added the following to my config.production.json file:

  "mail": {  
  "transport": "SMTP",  
  "options": {  
    "service": "Mailgun",  
    "host": "",  
    "port": "465",  
	"secure": true,
    "auth": {  
      "user": "<redacted>",
      "pass": "<redacted>"

I’ve confirmed my Mailgun SMTP credentials through the control panel as well as all other related info. My bulk e-mail functionality still works, but I’m receiving the same error with the above configuration now added to the config.production.json file.

To find the config file, I navigated to /appdata/ghost/config.production.json. My ‘appdata’ folder is mapped to /var/lib/ghost/content.

Config file looks good. I don’t recognise the paths though (but, to be fair, I’m not familiar with the Docker setup!). An easy way to check it’s the right config file might be to corrupt it (just add some arbitrary text in the middle that isn’t JSON formatted) and restart Ghost - it should say “A SystemError occurred.” and refuse to start.

The only thing that makes me suspicious is that the config file should be in the directory above content. For example:

$ ls -l
current -> /var/www/empirical-ghost/versions/4.16.0

I seem to recall seeing that Docker doesn’t use a config file - everything is configured using environment variables instead.

See: Docker -> Ghost - Cant find the config file

Also, this person knows how to do it: Mailgun SSLv3 error in Docker after updating SSL certificate - #2 by twelvetables

1 Like

Hi Halpdesk,

As EmpiricalEE noted, Docker doesn’t use a config file for Ghost, it uses environment variables (that you can define in a .env file).

Ghost explains how to use environment variables for your config here. TL;DR, instead of nesting items in JSON, you separate them with double underscores.

Dave Jansen has a great blog post on how to properly deploy Ghost. I made some minor modifications but by-and-large used his setup. It works great.


  "mail": {  
  "options": {  
    "host": "",  

would become:

mail__options__host: ''

You can see my docker config at:

(I have removed the Matomo portion of that config, but I can share with you over DM if you would like).

Getting Ghost set up with Docker is a bit of a hassle the first time (only because you have to learn Docker), but if you make sure you use volumes, it is a breeze to maintain!! Upgrading Ghost isn’t done through the command line, but is done instead through a simple: docker-compose restart or a docker-compose down && docker-compose up -d.

Let me know if you have any additional questions!

All - thanks again for the responses. I was able to successfully configure transaction email in my Ghost instance using the appropriate environment variables.

Thank you!