Newsletter Email Settings

Hi everyone,

I’m encountering issues when trying to set custom newsletter and support emails.

If you’re looking for help, please provide information about your environment. If you delete this template and don’t provide any information, your topic will be automatically closed.

If you aren’t running the latest version of Ghost, the first thing we’ll ask you to do is update to the latest version of Ghost.

  • What’s your URL? This is the easiest way for others to help you
    https://quaero.world

  • What version of Ghost are you using? If it’s not the latest, please update Ghost first before opening your topic
    Ghost version 4.32.0

And

  • How was Ghost installed and configured?
    Self hosted on a Digital Ocean droplet.

  • What Node version, database, OS & browser are you using?
    • Node v16.13.1
    • OS: Ubuntu
    • Browser: Safari

  • What errors or information do you see in the console?

[2022-01-16 16:02:39] ERROR "POST /ghost/api/canary/admin/settings/members/email/" 400 5447ms

NAME: BadRequestError
MESSAGE: Failed Sending Email

level: normal

"Please see https://ghost.org/docs/config/#mail for instructions on configuring email."
EmailError: Failed to send email. Reason: Email has been temporarily rejected.
  • What steps could someone else take to reproduce the issue you’re having?
    Trying to set any custom email address.

Since there isn’t a lot of documentation around email setup for Ghost, I’m sharing the steps I took to solve my issue.

1 - Logging Mailgun’s response

First, I decided to log mailgun’s response by editing the core/server/services/mail/GhostMailer.js file. In the handleDirectransportResponse function, I added this snippet at the top to log the response directly to a file.

const fs = require('fs');
fs.writeFile("/var/www/ghost/test.log", JSON.stringify(response), function(err) {
    if(err) {
        return console.log(err);
    }
});

• Note that I’m writing to a file called test.log but you can choose your own. Just remember to allow the “ghost” user to write to that file using chown ghost [filename].

• I then restarted Ghost and reattempted the procedure.

2 - Analyzing the logs

With the logs in the test.log, I could finally start working on a solution. Here are the logs I got:

{"accepted":[],"rejected":[],"pending":[{"domain":"quaero.world","exchange":"••••••••••••••••••","recipients":["contact@quaero.world"],"response":"450 4.7.1 Client host rejected: cannot find your reverse hostname, [159.65.193.143]"}],"errors":[],"envelope":{"from":"noreply@quaero.world","to":["contact@quaero.world"]}}

• In my case, I had a reverse domain lookup issue.

3 - The fix

I’m hosting my blog on a DigitalOcean droplet. It turns out, DigitalOcean will properly set the reverse domain lookup only if your droplet’s name is your domain name. By simply changing my droplet’s name, I was able to set custom email addresses.