Ghost: The from address on the confirmation email for updating email in Admin Settings (Support/Newsletter) is incorrect
Issue Summary
Currently, using Ghost v4.0, if you try to update the emails in your Admin Settings of Ghost under Members->Email and try to update either support or newsletter, they are set to noreply@domain.tld
They should ideally use the “from” address if set in your config’s mail part.
To Reproduce
The bigger problem is not this, its the fact that if you set custom SMTP and even “from” address in your config’s mail part, and try to update the emails given in your Admin Area above, Ghost ignores whatever is set in your config and still uses noreply@domain.tld or no-reply@domain.tld which creates issue with SMTP config as when Ghost tries to send such mails (confirmation mails), the SMTP server will reject it as the “from” mail is different from the actual userid/smtp emailid.
Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?
This is how postfix (SMTP) logs it:
NOQUEUE: reject: RCPT from unknown[xx.xx.xx.xx]: 553 5.7.1 <noreply@dly.in>: Sender address rejected: not owned by user user1@dly.in; from=<noreply@dly.in> to=<user1@dly.in> proto=ESMTP helo=<[127.0.0.1]>
The logic for this part (and how I fixed it) lies here:
core/server/services/members/settings.js
This is how Ghost currently does it
const [,toDomain] = email.split('@');
let fromEmail = `noreply@${toDomain}`;
if (fromEmail === email) {
fromEmail = `no-reply@${toDomain}`;
}
Ideally it should atleast check if a from address exists in your config.mail or use the smtp id instead. This just limits the usage of mail and SMTP in general to a very handful of providers.
I had to fix it by overriding fromEmail to use email itself and then I was able to update the mail in my Admin:
let fromEmail = `noreply@${toDomain}`;
if (fromEmail === email) {
fromEmail = `no-reply@${toDomain}`;
}
fromEmail = email;
Technical details:
- Ghost Version: v4.0
- Node Version:
- Browser/OS: Chrome
- Database: MySQL
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 15
- Comments: 33 (9 by maintainers)
Links to this issue
Commits related to this issue
- ✨ Improved sending email addresses for self-hosters fixes https://github.com/TryGhost/Ghost/issues/12802 - You can choose any support and newsletter email address in the UI without verification (as ... — committed to SimonBackx/Ghost by SimonBackx 5 months ago
- ✨ Improved sending email addresses for self-hosters (#19617) ref https://github.com/TryGhost/Ghost/issues/12802 fixes DMA-27 - You can choose any support and newsletter email address in the UI w... — committed to TryGhost/Ghost by SimonBackx 5 months ago
Still running into the same issue. Related: #15191 #15222
So many people must be impacted by this…
Hi, I’d also like to provide more detail around this issue, caused a problem for me. Bit of background, I’ve successfully deployed an azure multi-container instance, with persistent storage (Azure File Share). It uses caddy docker image for lets-encrypt and reverse proxy, the mysql-8 docker image for DB and the docker image for ghost v5.
My compose file looks like this:
The accompanying local .env file defines these values as the MAILFROM and GHOSTURL.
MAILFROM=noreply@domain.tld GHOSTURL=https://blog.domain.tld
I also have my own postfix box. If a member attempts sign up, the mail from address used by Ghost is: noreply@blog.domain.tld, which is ignoring the ‘mail__from:’ set in the environment, further resulting in googlemail rejecting it as spam. This is because as you can see from the logs below, the mail has a from address of the default, ‘noreply@blog.domain.tld’ (undesired) and not ‘noreply@domain.tld’ as expected and defined in environment. See below [redacted] postfix mail log.
I have found though, going into /ghost/#/settings/members?showPortalSettings=true, under support email address, shows that it is indeed noreply@blog.domain.tld. Changing this too the desired email and confirming ownership by receipt, will change the address used for member sign-ups, after doing so, I now get this in the postfix logs.
Status 250 = Ok is basically smtp speak for, we got and will deliver your mail, sure enough, the google account received the mail.
So, why isn’t the environment variable defined for ‘mail__from’ being honoured? Restarting the container group does save the address so at least membership/transactional mails are functional, took a while to work this out mind.
Also, why the constraint for mailgun as bulk mail sender? SendGrid for example, offers 100 mails a month for free, using your own domain, whereas mailgun has an associated cost for the same service.
Better value proposition for a blogger just starting out.
Apologies for the long post, just thought it might help someone struggling with this same issue and to help understand and narrow down what needs fixing in a PR.
Great app btw, thanks
Anyone still facing this god forsaken issue, my fix still works except the location/file where you need to make the change has changed in latest ghost (v5) from
core/server/services/members/settings.jstocore/server/services/settings/settings-bread-service.jsAnd don’t forget to set the
fromfield in your config’s mail sectionThis is still an issue.
Supplying
mail__fromas an env var does not change the email from address in a container. Just tested on 4.36.1.🎉 This issue and related issues have been fixed in v5.78.0.
Changes in Ghost v5.78.0
mail.fromconfig will be the default address for all outgoing emails:ghost@domainemail addressnoreply@domainif no from address is setmail.fromconfig instead ofnoreply@domainif no support address is set.What do you need to do
mail.fromconfig. If nomail.fromconfig is set, we’ll continue to default tonoreply@domaineverywhere, just like before.We’ve updated the documentation about the config, and recommend to check out our post on the forum about DMARC alignment and the new requirements from Google and Yahoo.
Google and Yahoo are introducing major changes to enforce DMARC in the next 2 months. The core team is currently doing a larger piece of work to support DMARC alignment in email sending, which overlaps-with and will also resolve this issue.
These changes will be released in January 2024.
Woops sorry, edited my initial issue above. I am not frustrated as I found a way to fix it (albeit using a solution provided by another user in ghost forums facing same issue and pointing the problem in settings.js).
To try and explain it a bit more:
It seems Ghost core has zero interest in the issues that are collected then shelved in this Issue.
Interesting thing is GhostPro behaves similarly but they offer a fix. Upgrade to “business” plan and pay $$$$$ “though this does require a Business plan, alongside a $50/month add-on for support”
Correction: from support, " rather than seeing the ‘via m.ghost.io’ it would be ‘via your-custom-sending-domain.com’, e.g. the custom sending domain instead. "
@ErisDS @JohnONolan If I am mistaken and there is a good reason for how these issues are being handled please let me know.
Changing setting under
/ghost/#/settings/members?showPortalSettings=trueindeed solved my issueHope this PR gets merged soon https://github.com/TryGhost/Ghost/pull/15989
I did that fix and restarted the server and the mail is still being sent from noreply. Is there something i am missing . I have cleared the cache and tried too but it does not work
This is still a problem, using Ghost 4.18 with a custom SMTP server, ghost is not using the from adress specified in config and uses noreply@blog-domain.tld instead of mysmtpuser@mailserver.tld like said in config. Ghost should only use the noreply@domain.tld when no “mail__from” value is set
EDIT: if it can help my smtp server says this in the logs
as you see in the logs, I’ve set the from address to be “mysmtpuser@mailserver.tld” but ghost doesn’t send it with this address