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>"
      }
    }
  },
5 Likes

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

Thank you for this! You just solved my comment/membership problem!

1 Like

I had the exact same problem. It was mailgun. My free mailgun trail was expired and I saw the same error message. I didn’t want to use mailgun because it was way to expensive for me. So i chose Amazon Simple Email Service (SES). It is easy to setup and way too cheaper.

If you are hosting your website in a docker container, you can set environment variables to setup email, s3 storage, database and more.

I am getting this error as well. To solve this, I added my Namecheap - Private email smtp info and started to get another error. I simply want to activate comment feature, not into bulk emailing at the moment. Anyone has an idea why this happens?

I replaced my domain with myDomain in following snippets.
SMTP setting:

"mail": {
    "transport": "SMTP",
    "options": {
      "service": "Privateemail",
      "host": "mail.privateemail.com",
      "port": 465,
      "secure": true,
      "auth": {
        "user": "info@myDomain.com",
        "pass": "password"
      }
    }
  },

Error log:

NAME: EmailError
CODE: EENVELOPE
MESSAGE: Failed to send email. Reason: Can't send mail - all recipients were rejected: 553 5.7.1 <noreply@myDomain.com>: Sender address rejected: not owned by user info@myDomain.com.

level: normal

"Please see https://ghost.org/docs/config/#mail for instructions on configuring email."
Error: Can't send mail - all recipients were rejected: 553 5.7.1 <noreply@myDomain.com>: Sender address rejected: not owned by user info@myDomain.com
    at createMailError (/var/www/ghost/versions/5.11.0/core/server/services/mail/GhostMailer.js:67:12)
    at SMTPConnection._formatError (/var/www/ghost/versions/5.11.0/node_modules/nodemailer/lib/smtp-connection/index.js:787:19)
    at SMTPConnection._actionRCPT (/var/www/ghost/versions/5.11.0/node_modules/nodemailer/lib/smtp-connection/index.js:1629:28)
    at SMTPConnection.<anonymous> (/var/www/ghost/versions/5.11.0/node_modules/nodemailer/lib/smtp-connection/index.js:1582:30)
    at SMTPConnection._processResponse (/var/www/ghost/versions/5.11.0/node_modules/nodemailer/lib/smtp-connection/index.js:950:20)
    at SMTPConnection._onData (/var/www/ghost/versions/5.11.0/node_modules/nodemailer/lib/smtp-connection/index.js:752:14)
    at TLSSocket.SMTPConnection._onSocketData (/var/www/ghost/versions/5.11.0/node_modules/nodemailer/lib/smtp-connection/index.js:191:44)
    at TLSSocket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:206:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
1 Like

For those who has same issue with me: I added alias in Namecheap private email for noreply keyword. It worked.

1 Like