Custom Email Configuration - Failed to send magic link email

I installed ghost on a droplet on Digital Ocean. I install it directly from the marketplace. I bought a custom domain from Namecheap and also an email. I got the domain working. But when I setup my email. The email is being sent from noreply@atharv’.‘vadehra’.‘me according to error logs. I want it to be sent from atharv@vadehra’.'me.

Config File:

"mail": {
    "transport": "SMTP",
    "options": {
      "host": "mail'.'privateemail'.'com",
      "port": 465,
      "secure": true,
      "from": "atharv@vadehra'.'me",
      "auth": {
        "user": "atharv@vadehra'.'me",
        "pass": "**********************"
      }
    }
  },

Error Log:

“Error: Can’t send mail - all recipients were rejected: 553 5.7.1 <noreply@vadehra’.‘me>: Sender address rejected: not owned by user atharv@vadehra’.'me\n at createMailError (/var/www/ghost/versions/5.47.1/core/server/services/mail/GhostMailer.js:68:12)\n at SMTPConnection._formatError (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:790:19)\n at SMTPConnection._actionRCPT (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:1632:28)\n at SMTPConnection. (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:1585:30)\n at SMTPConnection._processResponse (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:953:20)\n at SMTPConnection._onData (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:755:14)\n at TLSSocket.SMTPConnection._onSocketData (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:193:44)\n at TLSSocket.emit (node:events:513:28)\n at addChunk (node:internal/streams/readable:315:12)\n at readableAddChunk (node:internal/streams/readable:289:9)\n at TLSSocket.Readable.push (node:internal/streams/readable:228:10)\n at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)”,“hideStack”:false},“msg”:“Failed to send email. Reason: Can’t send mail - all recipients were rejected: 553 5.7.1 <noreply@vadehra’.'me>: Sender address rejected: not owned by user atharv@vadehra.me.”,“time”:“2023-05-20T18:09:37.811Z”,“v”:0}

Just upon first glance, without digging deeper into the logs, I believe that there might be an issue with the way you wrote the email addresses.

You wrote “host”: "mail’.‘privateemail’.‘com",, wich additional single quotes in there. The correct way would be “host”: "mail.privateemail.com",.

Same with your “from” and “user” fields. Instead of "atharv@vadehra’.‘me", try "atharv@vadehra.me" there.

Let us know if that works!

I added ’ ’ because new users cannot add more than 3 links on this Forum :grin:

Ahh I see – could have picked up on that :sweat_smile:

Just had another deeper look then.

This seems to be your current configuration:

{
	"mail": {
		"transport": "SMTP",
		"options": {
			"host": "mail.privateemail.com",
			"port": 465,
			"secure": true,
			"from": "atharv@vadehra.me",
			"auth": {
				"user": "atharv@vadehra.me",
				"pass": "**********************"
			}
		}
	}
}

As you can see, you put the from property into the options. However, this should be one level up, putting it on the same level as transport. Have a look at the documentation here for more context.

Here’s the fixed configuration:

{
	"mail": {
		"from": "atharv@vadehra.me",
		"transport": "SMTP",
		"options": {
			"host": "mail.privateemail.com",
			"port": 465,
			"secure": true,
			"auth": {
				"user": "atharv@vadehra.me",
				"pass": "**********************"
			}
		}
	}
}

Hope that fixes the problem :slight_smile:

1 Like

I still got the same log error as before. Try and signup on atharv.vadehra.me and then inspect the page. I have tried multiple things, couldn’t find any solution.

Did you restart Ghost after making the config changes?

Also, <noreply@vadehra.me>: Sender address rejected: not owned by user atharv@vadehra.me suggests that the server is rejecting the sender. Have you created an alias for noreply@vadehra.me?

Yes, I restarted ghost.
Can’t I send my emails from atharv@vadehra.me. I not how do you suggest me to create an alias. I tried looking through www.privateemail.com.

Look at the service provider’s help pages, e.g., …

{
“url”: “https://atharv.vadehra .me”,
“server”: {
“port”: 2368,
“host”: “127.0.0.1”
},
“database”: {
“client”: “mysql”,
“connection”: {
“host”: “localhost”,
“user”: “ghost-554”,
“password”: “",
“port”: 3306,
“database”: “ghost_production”
}
},
“mail”: {
“transport”: “SMTP”,
“options”: {
“host”: “mail.privateemail .com”,
“port”: 465,
“secure”: true,
“from”: “atharv@vadehra .me”,
“auth”: {
“user”: “atharv@vadehra .me”,
“pass”: "
**”
}
}
},
“logging”: {
“transports”: [
“file”,
“stdout”
]
},
“process”: “systemd”,
“paths”: {
“contentPath”: “/var/www/ghost/content”
}
}

This is my config file. Now the error is that the mail are sent from noreply@atharv. vadehra".“me. I bought a domain from namecheap which is vadehra”."me. I have tried everything changing the from attribute but nothing is working. I create an Alias noreply@vadehra.me

The from property is still on the wrong level.

You need to move it outside the “options” object, one level up, as mentioned here: Custom Email Configuration - Failed to send magic link email - #4 by jannis

Typically, noreply@… is used in the from field because it’s an unmonitored email address. The sender address and userid are different.

Either follow advice by @jannis, and correct the config, or create an alias in your email service.

Config given by @jannis is also not working. Still the sending address is noreply@atharv.vadehra.me. I tried changing the location of the from attribute. Still It is not working.

That is surprising, since this is the only place within Ghost where the from-email for transactional emails is set.

The noreply-email is used by Ghost if no configuration is found and is basically a fallback.

I have a strong feeling that there is still something wrong with the configuration file. Can you send us the entire file again, with the from property on the correct level? I’ll try and run it on my local machine then to test it and eliminate any errors.

{
“url”: “https://atharv.vadehra.me”,
“server”: {
“port”: 2368,
“host”: “127.0.0.1”
},
“database”: {
“client”: “mysql”,
“connection”: {
“host”: “localhost”,
“user”: “ghost-554”,
“password”: “”",
“port”: 3306,
“database”: “ghost_production”
}
},
“mail”: {
“from”: “atharv@vadehra’.'me”,
“transport”: “SMTP”,
“options”: {
“host”: “mail.privateemail’.'com”,
“port”: 465,
“secure”: true,
“auth”: {
“user”: “atharv@vadehra.''me”,
“pass”: "
**"
}
}
},
“logging”: {
“transports”: [
“file”,
“stdout”
]
},
“process”: “systemd”,
“paths”: {
“contentPath”: “/var/www/ghost/content”
}
}

I read the code for this config file. I that also I could see the form attribute but it is not reading the from attribute in the file.

Please post this config unedited, and use the Preformatted text menu button or surround the text with backticks, e.g.,

```

"database": {
"client": "mysql”,
"connection": {

```.

Thanks.

{
  "url": "https://atharv.vadehra.me",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "localhost",
      "user": "ghost-554",
      "password": "******",
      "port": 3306,
      "database": "ghost_production"
    }
  },
  "mail": {
    "from": "atharv@vadehra.me",
    "transport": "SMTP",
    "options": {
      "host": "mail.privateemail.com",
      "port": 465,
      "secure": true,
      "auth": {
        "user": "atharv@vadehra.me",
        "pass": "*******"
      }
    }
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/www/ghost/content"
  }
}

The JSON is valid. Please share the error log.

{"name":"Log","hostname":"ghostonubuntu2204-s-1vcpu-1gb-blr1-
01","pid":211762,"level":50,"version":"5.47.1","err":{"id":"440e9970-fadc-11ed-9f77-
ad3b785d7a29","domain":"https://atharv.vadehra.me","code":"EENVELOPE","name":"EmailError","st
atusCode":500,"level":"normal","message":"Failed to send email. Reason: Can't send mail - all 
recipients were rejected: 553 5.7.1 <noreply@atharv.vadehra.me>: Sender address rejected: not 
owned by user atharv@vadehra.me.","help":"\"Please see https://ghost.org/docs/config/#mail for 
instructions on configuring email.\"","stack":"Error: Can't send mail - all recipients were rejected: 553 
5.7.1 <noreply@atharv.vadehra.me>: Sender address rejected: not owned by user 
atharv@vadehra.me\n    at createMailError 
(/var/www/ghost/versions/5.47.1/core/server/services/mail/GhostMailer.js:68:12)\n    at 
SMTPConnection._formatError (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-
connection/index.js:790:19)\n    at SMTPConnection._actionRCPT 
(/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:1632:28)\n  

  at SMTPConnection.<anonymous> 
(/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:1585:30)\n 
   at SMTPConnection._processResponse 
(/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:953:20)\n  
  at SMTPConnection._onData (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp
-connection/index.js:755:14)\n    at TLSSocket.SMTPConnection._onSocketData 
(/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:193:44)\n 
   at TLSSocket.emit (node:events:513:28)\n    at addChunk 
(node:internal/streams/readable:315:12)\n    at readableAddChunk 
(node:internal/streams/readable:289:9)\n    at TLSSocket.Readable.push 
(node:internal/streams/readable:228:10)\n    at TLSWrap.onStreamRead 
(node:internal/stream_base_commons:190:23)","hideStack":false},"msg":"Failed to send email. 
Reason: Can't send mail - all recipients were rejected: 553 5.7.1 <noreply@atharv.vadehra.me>: 
Sender address rejected: not owned by user atharv@vadehra.me.","time":"2023-05-
25T09:12:25.995Z","v":0}

Please post something that is readable, i.e., with line breaks.

Sorry for the inconvenience.

{"name":"Log","hostname":"ghostonubuntu2204-s-1vcpu-1gb-blr1-
01","pid":211762,"level":50,"version":"5.47.1","err":{"id":"440e9970-fadc-11ed-9f77-
ad3b785d7a29","domain":"https://atharv.vadehra.me","code":"EENVELOPE","name":"EmailError","st
atusCode":500,"level":"normal","message":"Failed to send email. Reason: Can't send mail - all 
recipients were rejected: 553 5.7.1 <noreply@atharv.vadehra.me>: Sender address rejected: not 
owned by user atharv@vadehra.me.","help":"\"Please see https://ghost.org/docs/config/#mail for 
instructions on configuring email.\"","stack":"Error: Can't send mail - all recipients were rejected: 553 
5.7.1 <noreply@atharv.vadehra.me>: Sender address rejected: not owned by user 
atharv@vadehra.me\n    at createMailError 
(/var/www/ghost/versions/5.47.1/core/server/services/mail/GhostMailer.js:68:12)\n    at 
SMTPConnection._formatError (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-
connection/index.js:790:19)\n    at SMTPConnection._actionRCPT 
(/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:1632:28)\n  

  at SMTPConnection.<anonymous> 
(/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:1585:30)\n 
   at SMTPConnection._processResponse 
(/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:953:20)\n  
  at SMTPConnection._onData (/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp
-connection/index.js:755:14)\n    at TLSSocket.SMTPConnection._onSocketData 
(/var/www/ghost/versions/5.47.1/node_modules/nodemailer/lib/smtp-connection/index.js:193:44)\n 
   at TLSSocket.emit (node:events:513:28)\n    at addChunk 
(node:internal/streams/readable:315:12)\n    at readableAddChunk 
(node:internal/streams/readable:289:9)\n    at TLSSocket.Readable.push 
(node:internal/streams/readable:228:10)\n    at TLSWrap.onStreamRead 
(node:internal/stream_base_commons:190:23)","hideStack":false},"msg":"Failed to send email. 
Reason: Can't send mail - all recipients were rejected: 553 5.7.1 <noreply@atharv.vadehra.me>: 
Sender address rejected: not owned by user atharv@vadehra.me.","time":"2023-05-
25T09:12:25.995Z","v":0}

Thank you