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

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

This worked for me. Ironically, I think the order matters here, since I had all the same information as you @mjw but in a different order within the JSON. Once I copied your template into my configuration and edited with the info specific to my Mailgun account, it worked like a charm.

Thank you so much!

1 Like

Sorry to bring up a quasi dead post, but how would you have this added in your docker/docker-compose? I have a bunch of mail_options in my compose file, but it looks like those were ignored when I look at my config.prod.

See this post:

See I have that, but the config.production file just has “Direct” and it gives me a magic link error when someone attempts to subscribe.

Please remember to NOT Reply All when replying to this email.

IIRC, and I don’t use Docker for Ghost, config.production.json isn’t used by Docker; you have to pass the relevant environment variables for your setup.

This is a thread on a public forum, not an email conversation.

Hello, I got exactly the same error but in my case, it’s because I’m using a free account.

In /var/www/my-super-blog-on-top, I ran this command:

journalctl -fu '*ghost*'

Then, I tried to generate a magic link once again and got these logs:

Jan 04 08:45:08 vps-290d48db node[133743]: [2024-01-04 08:45:08] ERROR Failed to send email. Reason: Data command failed: 421 Domain mail.my-super-blog-on-top.com is not allowed to send: Free accounts are for test purposes only. Please upgrade or add the address to authorized recipients in Account Settings..
Jan 04 08:45:08 vps-290d48db node[133743]:
Jan 04 08:45:08 vps-290d48db node[133743]: Failed to send email. Reason: Data command failed: 421 Domain mail.my-super-blog-on-top.com is not allowed to send: Free accounts are for test purposes only. Please upgrade or add the address to authorized recipients in Account Settings..
Jan 04 08:45:08 vps-290d48db node[133743]: "Please see https://ghost.org/docs/config/#mail for instructions on configuring email."
Jan 04 08:45:08 vps-290d48db node[133743]: Error ID:
Jan 04 08:45:08 vps-290d48db node[133743]:     9046afb0-aadd-11ee-96b4-45ad56f06527
Jan 04 08:45:08 vps-290d48db node[133743]: Error Code:
Jan 04 08:45:08 vps-290d48db node[133743]:     EENVELOPE
Jan 04 08:45:08 vps-290d48db node[133743]: ----------------------------------------
Jan 04 08:45:08 vps-290d48db node[133743]: Error: Data command failed: 421 Domain mail.my-super-blog-on-top.com is not allowed to send: Free accounts are for test purposes only. Please upgrade or add the address to authorized recipients in Account Settings.
.
.
.
Jan 04 08:45:08 vps-290d48db node[133743]: [2024-01-04 08:45:08] INFO "POST /members/api/send-magic-link/" 400 404ms

This is pretty explicit. However, it’s sad because I just started my blog and can’t afford the Foundation offer, but that’s another subject.

I hope it helps!

(ps: it’s been 11 months since the last reply was written. I was facing the same error, but not for the same reason that I couldn’t solve for hours. I wanted to share it, sorry if it was not appropriate.)

Edit: I don’t know why but the “reset password” email is still being sent + I found a solution thanks to @jannis !

Have a look here: How to Downgrade to the Flex Plan in Mailgun in 2023

2 Likes

Thank you so much, I also started a self-hosting plan with Digital Ocean and the official guides are not working for the email part.

They should update the docs.

Also I had issues with free RAM (1GB was consuming too rapidly) and hopefully I solved thanks to this amazing forum