Custom Email Configuration - Failed to send magic link email

You have the same error, i.e., sender email rejected.

Make sure your credentials for privateemail.com are correct. For example, does it require an app-specific password? Moreover, the sender and authenticated user probably need to be the same for your service unless you create an alias for the alternative address.

No luck. Any other suggestions.

What did you try or check?

From the Private Email support pages I note:

Outgoing server (SMTP): 465 port for SSL, 587 for TLS/STARTTLS

Outgoing server authentication should be switched on, SPA (secure password authentication) must be disabled.

Have you followed their guide? If not, double-check your email settings.

You could test the connection using an SSH session and SWAKS.

You can install this using APT on Ubuntu. A test would look something like this:

swaks --to TEST-EMAIL --server smtp.privateemail:587 -tls --auth-user atharv@vadehra.me

I’ve used STARTLS (587) since this is preferable to 465.

Connection test was successful but even after changing the port I still am facing the same error.

Why you don’t use SMTP Mailgun instead, it just cost you 5 minutes to create account and free. BTW, Mailgun is used for ghost newsletter, you must have one for sure.

I had already bought a domain and a mail box for it is necessary for me to use that only. It is kind of a task which I have been given.

Maybe my contribution to this conversation is too obvious, but for me the solution was to correctly place the link I created in mailgun. As you can see in the image.

In ghost you have 3 things about email:

  1. Email Transaction which should use SMTP like Amazon or Mailgun for better delivery. Setup with config.json.
  2. Email Newsletter which use Mailgun API, you can setup from ghost admin.
  3. Mailbox to send/received the support email which setup on ghost admin too. It will need you verify to change support email address.

I personally always use Mailgun for 1 and 2 to save time and better productivity because it is easy setup.

You have a Namecheap Mailbox which can use for 3. Not totally waste money.

1 Like

This service is essentially for receiving email, and isn’t a relay service.

Nonetheless, it’s not clear what diagnostic steps you’ve taken. Did you, for example, manage to send a test message via SWAKS? The error message suggests that the problem is with your email service, and it would be good to confirm this.

Moreover, simply changing port to 587 won’t work as you’ll need to adjust the config for TLS and insecure negotiation.

This is for newsletters, not transactional email.

Same here, and the ideal solution. The OP should do this, and use Private Email for receiving messages.

I tried SWAK. It sends the test email successfully.

Sharing the output from the command would be helpful.

Command I used :

swaks --to atharvrocks14@gmail.com  --server mail.privateemail.com:587 -tls --auth-user atharv@vadehra.me --from noreply@vadehra.me
=== Trying mail.privateemail.com:587...
=== Connected to mail.privateemail.com.
<-  220 PrivateEmail.com prod Mail Node
 -> EHLO ghostonubuntu2204-s-1vcpu-1gb-blr1-01
<-  250-mta-15.privateemail.com
<-  250-PIPELINING
<-  250-SIZE 81788928
<-  250-ETRN
<-  250-AUTH PLAIN LOGIN
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250-CHUNKING
<-  250 STARTTLS
 -> STARTTLS
<-  220 Ready to start TLS
=== TLS started with cipher TLSv1.3:TLS_AES_128_GCM_SHA256:128
=== TLS no local certificate set
=== TLS peer DN="/CN=privateemail.com"
 ~> EHLO ghostonubuntu2204-s-1vcpu-1gb-blr1-01
<~  250-mta-15.privateemail.com
<~  250-PIPELINING
<~  250-SIZE 81788928
<~  250-ETRN
<~  250-AUTH PLAIN LOGIN
<~  250-ENHANCEDSTATUSCODES
<~  250-8BITMIME
<~  250 CHUNKING
 ~> AUTH LOGIN
<~  334 VXNlcm5hbWU6
 ~> YXRoYXJ2QHZhZGVocmEubWU=
<~  334 UGFzc3dvcmQ6
 ~> QXRoYXJ2dmFkZWhyYTE3
<~  235 2.7.0 Authentication successful
 ~> MAIL FROM:<noreply@vadehra.me>
<~  250 2.1.0 Ok
 ~> RCPT TO:<atharvrocks14@gmail.com>
<~  250 2.1.5 Ok
 ~> DATA
<~  354 End data with <CR><LF>.<CR><LF>
 ~> Date: Sat, 10 Jun 2023 17:25:22 +0000
 ~> To: atharvrocks14@gmail.com
 ~> From: noreply@vadehra.me
 ~> Subject: test Sat, 10 Jun 2023 17:25:22 +0000
 ~> Message-Id: <20230610172522.441885@ghostonubuntu2204-s-1vcpu-1gb-blr1-01>
 ~> X-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/
 ~> 
 ~> This is a test mailing
 ~> 
 ~> 
 ~> .
<~  250 2.0.0 Ok: queued as E084018000A2
 ~> QUIT
<~  221 2.0.0 Bye
=== Connection closed with remote host.

Your config needs to include this:

  "mail": {
    "from": "noreply@vadehra.me",
    "transport": "SMTP",
    "options": {
      "host": "mail.privateemail.com",
      "port": 587,
      "service": "PrivateEmail.com",
      "secure": false,
      "requireTLS": true,
      "auth": {
        "user": "atharv@vadehra.me",
        "pass": "password-used-with-swaks"
      }
    }
  },

I am still receiving the same error.

{"name":"Log","hostname":"ghostonubuntu2204-s-1vcpu-1gb-blr1-01","pid":467679,"level":50,"version":"5.47.1","err":{"id":"60f5cd80-091c-11ee-8636-4d5037525a41","domain":"https://atharv.vadehra.me","code":"EENVELOPE","name":"EmailError","statusCode":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-06-12T12:26:38.555Z","v":0}
ghost-mgr@ghostonubuntu2204-s-1vcpu-1gb-blr1-01:/var/www/ghost$ 

You’re not using the same email address you used with Swaks: noreply@atharv.vadehra.me.

Also, the sending domain is not the same since you’re using a subdomain with Ghost. This is the most likely cause, i.e., PrivateEmail doesn’t recognize the sender (didn’t this get covered before?) You need to create an alias or use the config I shared.

Alternatively, setup Mailgun for sending transactional email, which can be done for a subdomain whilst keeping the root domain with PrivateEmail.

I used the same email with swaks in the config which is noreply@vadehra.me. I have made an alias like you asked before. Ghost is sending the email form noreply@atharv.vadehra.me . I want it to be sent from noreply@vadehra.me.

Then you need to set the correct email in Ghost: production.config.json and possibly under Email newsletter > Sender email address, since this defaults to noreply@ the hosted domain.

I tried to change the default email address in Email Newsletter > Sender’s Address. It shows an error with a different email address which is no-reply@vadehra.me.

The issue is that Ghost is setup for a subdomain, but your email service isn’t. This is why you need to create an alias for atharv.vadehra.me.

To confirm this try Swaks with the same settings:

swaks --to atharvrocks14@gmail.com --server mail.privateemail.com:587 -tls --auth-user atharv@vadehra.me --from noreply@atharv.vadehra.me

ghost-mgr@ghostonubuntu2204-s-1vcpu-1gb-blr1-01:~$ swaks --to atharvrocks14@gmail.com --server mail.privateemail.com:587 -tls --auth-user atharv@vadehra.me --from noreply@atharv.vadehra.me
Password: ******
=== Trying mail.privateemail.com:587...
=== Connected to mail.privateemail.com.
<-  220 PrivateEmail.com prod Mail Node
 -> EHLO ghostonubuntu2204-s-1vcpu-1gb-blr1-01
<-  250-mta-10.privateemail.com
<-  250-PIPELINING
<-  250-SIZE 81788928
<-  250-ETRN
<-  250-AUTH PLAIN LOGIN
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250-CHUNKING
<-  250 STARTTLS
 -> STARTTLS
<-  220 Ready to start TLS
=== TLS started with cipher TLSv1.3:TLS_AES_128_GCM_SHA256:128
=== TLS no local certificate set
=== TLS peer DN="/CN=privateemail.com"
 ~> EHLO ghostonubuntu2204-s-1vcpu-1gb-blr1-01
<~  250-mta-10.privateemail.com
<~  250-PIPELINING
<~  250-SIZE 81788928
<~  250-ETRN
<~  250-AUTH PLAIN LOGIN
<~  250-ENHANCEDSTATUSCODES
<~  250-8BITMIME
<~  250 CHUNKING
 ~> AUTH LOGIN
<~  334 VXNlcm5hbWU6
 ~> YXRoYXJ2QHZhZGVocmEubWU=
<~  334 UGFzc3dvcmQ6
 ~> QXRoYXJ2dmFkZWhyYTE3
<~  235 2.7.0 Authentication successful
 ~> MAIL FROM:<noreply@atharv.vadehra.me>
<~  250 2.1.0 Ok
 ~> RCPT TO:<atharvrocks14@gmail.com>
<~* 553 5.7.1 <noreply@atharv.vadehra.me>: Sender address rejected: not owned by user atharv@vadehra.me
 ~> QUIT
<~  221 2.0.0 Bye
=== Connection closed with remote host.

This is the output.