Can't modify "From address" and problems with configuring MailGun on subdomain

Hello, people!

I never managed to setup properly mail settings in Ghost since last year and gave up. Now I tried once again and well it’s not working and I am out of ideas.

  1. We are been using Mailgun on our main domain for a long time and it works fine
  2. Ghost runs on subdomain blog.domain.tld
  3. Then I try to modify " From address" in Labs there is short “sending” and then red button with “Retry”. No matter what kind of “From address” I try to make.
  4. All emails are being sent with @subdomain.domain.tld address. There is just emptiness before @.
  5. IP addresses are whitelisted just in case in Mailgun (VPS and CloudFlare)
  6. If I try to subscribe with Gmail domain it says " Please enter a valid email address!", but works totally fine with any other domain name.

Is this so complicated, because our blog runs on subdomain? What am I missing…?

Logs than I try to modify “From address” in Labs:

[2020-06-28 12:34:37] ERROR “POST /ghost/api/v3/admin/settings/members/email/” 400 29ms

NAME: BadRequestError
MESSAGE: Failed to send email.

level: normal

“Please see https://ghost.org/docs/concepts/config/#mail for instructions on configuring email.”
BadRequestError: Failed to send email.
at new BadRequestError (/var/www/ghost/versions/3.21.0/node_modules/ghost-ignition/lib/errors/index.js:113:23)
at Object.query (/var/www/ghost/versions/3.21.0/core/server/api/canary/settings.js:145:23)

EmailError: Failed to send email.
at EmailError.GhostError (/var/www/ghost/versions/3.21.0/node_modules/@tryghost/errors/lib/errors.js:10:26)
at new EmailError (/var/www/ghost/versions/3.21.0/node_modules/@tryghost/errors/lib/errors.js:34:20)
at createMailError (/var/www/ghost/versions/3.21.0/core/server/services/mail/GhostMailer.js:51:12)
at EventEmitter. (/var/www/ghost/versions/3.21.0/core/server/services/mail/GhostMailer.js:112:24)
at Object.onceWrapper (events.js:286:20)
at EventEmitter.emit (events.js:198:13)
at EventEmitter.emit (domain.js:448:20)
at DirectMailer. (/var/www/ghost/versions/3.21.0/node_modules/directmail/lib/mailer.js:138:30)
at QueryReqWrap.onresolve [as oncomplete] (dns.js:196:10)

Logs than I try to subscribe with Gmail address:

[2020-06-28 12:36:40] ERROR

NAME: EmailError
MESSAGE: Failed to send email. Reason: Mail from command failed - 555 5.5.2 Syntax error. p9si11031054wrx.301 - gsmtp.

level: normal

“Please see https://ghost.org/docs/concepts/config/#mail for instructions on configuring email.”
EmailError: Failed to send email. Reason: Mail from command failed - 555 5.5.2 Syntax error. p9si11031054wrx.301 - gsmtp.
at EmailError.GhostError (/var/www/ghost/versions/3.21.0/node_modules/@tryghost/errors/lib/errors.js:10:26)
at new EmailError (/var/www/ghost/versions/3.21.0/node_modules/@tryghost/errors/lib/errors.js:34:20)
at createMailError (/var/www/ghost/versions/3.21.0/core/server/services/mail/GhostMailer.js:51:12)
at EventEmitter. (/var/www/ghost/versions/3.21.0/core/server/services/mail/GhostMailer.js:117:28)
at Object.onceWrapper (events.js:286:20)
at EventEmitter.emit (events.js:198:13)
at EventEmitter.emit (domain.js:448:20)
at DirectMailer. (/var/www/ghost/versions/3.21.0/node_modules/directmail/lib/mailer.js:185:42)
at SMTPClient. (/var/www/ghost/versions/3.21.0/node_modules/directmail/lib/mailer.js:277:9)
at Object.onceWrapper (events.js:286:20)
at SMTPClient.emit (events.js:198:13)
at SMTPClient.EventEmitter.emit (domain.js:448:20)
at SMTPClient._onError (/var/www/ghost/versions/3.21.0/node_modules/simplesmtp/lib/client.js:373:10)
at SMTPClient._actionMAIL (/var/www/ghost/versions/3.21.0/node_modules/simplesmtp/lib/client.js:981:14)
at SMTPClient._onData (/var/www/ghost/versions/3.21.0/node_modules/simplesmtp/lib/client.js:354:29)
at Socket.emit (events.js:198:13)
at Socket.EventEmitter.emit (domain.js:448:20)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

[2020-06-28 12:36:40] INFO “POST /members/api/send-magic-link/” 500 71ms

  • What version of Ghost are you using?
    Ghost version: 3.21.0
    Ghost-CLI version: 1.14.1
    Slightly modified version of Casper 3.0.12
  • How was Ghost installed and configured?
    On VPS, Ubuntu 18.04

Modifying the from address requires an email to send for you to confirm you own the address. Both that and the subscribe emails you’re trying to send use the config in your config.production.json, and as you can see both are throwing errors.

If you want a hand debugging your config, you need to share it :slight_smile:

Please also share the exact details of the from address you are trying to set.

1 Like

Hi!

I tried for example noreply@blog.domain.com and noreply@domain.com, bot are not working. Actually none of custom names are working :frowning:

I tried adding “from”: “noreply@mydomaincom”, but nothing happens.

Config.production.json looks like this:

{
“url”: “https://blog.domain.com”,
“server”: {
“port”: 2368,
“host”: “127.0.0.1”
},
“database”: {
“client”: “mysql”,
“connection”: {
“host”: “localhost”,
“user”: “hidden”,
“password”: “hidden”",
“database”: “ghostdb”
}
},
“mail”: {
“transport”: “Direct”
},
“logging”: {
“transports”: [
“file”,
“stdout”
]
},
“process”: “systemd”,
“paths”: {
“contentPath”: “/var/www/ghost/content”
}
}

You need to configure mail - both of the error messages you saw directed you to this page of the docs:

If you’ve configured mailgun under member settings in labs, this is for bulk email (sending newsletters) only. All your transactional email is currently configured as “direct” but needs to be configured to use an SMTP service of some kind.

Update! I found solution, which was super complicated, but it worked.

  1. I had to setup Amazon SES and verify subdomain.main.tld
  2. After that I had to add “marketing@main.tld” domain to trusted ones in Amazon SES
  3. This way I can finally modify “From address” to marketing@main.tld.

After that you can remove AWS SES and configure Mailgun in Ghost labs and configuration file.

That is incorrect, if you remove this config you will not be able to send any transactional email, meaning no one will be able to subscribe. Internal invites and password reset emails will also fail to send.

Why? It works fine.

I just switched from SES to Mailgun and changed configuration (SMTP settings). Otherwise there is no way to modify from address.

The mailgun configuration in Ghost labs is only for sending newsletters.

If you’ve configured mailgun in config.production.json as well as labs, then yes it will work fine.

1 Like