Failed to send magic link email Error when trying to sign up

Hello,
I’m trying to make it possible that members can sign up for my page and receive the newsletter.
Sadly whenever I try to sign-up it shows me the error “Failed to send magic link email”.

Now I’m at a loss on how to fix this issue and where to even look. Sending test mails through Mailgun works. I use the Ghost CMS droplet from Digital Ocean. My Ghost version is 5.2.2.

This is how the error looks like:

If I could get any help on this I would appreciate it A LOT. Even just a hint to where to problem comes from would be amazing!

Have you configured Ghost to use Mailgun for transactional emails, or are these handled by your server?

The easiest way to check is to look at production.config.json under Mail.

If you haven’t setup an MTA this will probably fail. Mailgun needs configuring, but not through the admin pages. See the documentation:

1 Like
  • Check your ghost logs on the server with: journalctl -u '*ghost*'.
  • Check that you actually send an email from your server with: echo "something" | mailx -s "subject" recipient@somewhere.com
1 Like

I don’t know how transactional Email are configured. I just setup Ghost cms over digital ocean, added Stripe and then added Mailgun like it is explained in the Ghost docs. Is there something that is that I am missing? What is an MTA?
I have configured the config.production.json. The mail part looks like this:
“mail”: {
“transport”: “SMTP”,
“options”: {
“service”: “Mailgun”,
“host”: “smtp.eu.mailgun.org”,
“port”: 587,
“secure”: “true”,
“auth”: {
“user”: “postmaster@mg.bryanhogan.me”,
“pass”: “”
}
}
},

Where do I need to write this?
Writing journalctl -u '*ghost*' under /var/www/ghost just says “No journal files were found.”

I think I found something. Changing the port to 465 and secure to “false” in the config.production.json file fixes the error.
But setting to secure to “false” is not optimal, right?

Okay, so you have set up Mailgun for transactional email. However, for this to work, you’ll need to make sure you’ve setup DNS correctly for your domain. Additionally, try port 465, and make sure you have outgoing firewall rules setup for these ports.

1 Like

If you followed steps to have the service managed by systemd, that would show you the server logs that systemd has for the service.

Using port 465 for SMTP is out of date and deprecated and should be used unless necessary, so yes, it could cause a problem later.

This is a good time to learn where the logs for your ghost service or started.

You could try ghost ls to list your ghost instances and then ghost log [name] to review the logs. That might work if you didn’t set up a systemd service to management.

Systemd is helpful to make sure the service starts at boot and gets restarted if it crashes. The systemd service is set up for you when running ghost setup.

No. However, port 465 is implicitly a TLS connection (whereas 587 is STARTTLS, which means the conversation starts in plain text.) The preferred port nowadays is 587, but 465 does work with Mailgun. What happens if you change to "secure": "true",?

1 Like

Setting "secure": "true", also works. The error does not appear. So the problem was with the port I assume.

I just checked more config, and I’m using 465. I have a feeling I had an issue with 587, but can’t remember for sure.

Furthermore, I’ll change to 587, and provide an update.

Edit: 587 doesn’t work for me either. I’ll need to look into this as port 465 is no longer RFC compliant as @markstos alluded.

I’m trying to get 587 working on my server.

First, I checked that I could communicate with Mailgun:

telnet smtp.eu.mailgun.org 587

Since this worked, that would rule out Linode blocking the port, so the problem should to be on my setup. However, I’m having trouble getting things to work consistently, so I think this is something for the weekend. :slight_smile:

Okay, @Bryan0, @markstos, I think I got it sorted.

This config seems to work.

  "mail": {
    "from": "<email>",
    "transport": "SMTP",
    "options": {
      "host": "smtp.eu.mailgun.org",
      "port": 587,
      "service": "Mailgun",
      "secure": false,
      "requireTLS": true,
      "auth": {
        "user": "<email>",
        "pass": "<password>"
      }
    }
  },
1 Like

For Gmail, remove the host, port, and secure options:

     "mail": {
       "from": "'X X' <xx@xx.xx>",
       "transport": "SMTP",
       "options": {
         "service": "Gmail",
         "auth": {
           "user": "X",
           "pass": "X"
         }
       }
     },
1 Like