When sending member subscription emails we include the site title in the "From" field. When the site title starts with an @ this results in an error:
EmailError: 'from' parameter is not a valid address. please check documentation
@testEmail should be sent but instead you get an error.
Experiencing issue here with the from value not properly escaping characters:
https://forum.ghost.org/t/differing-from-addresses-from-newsletter-emails-and-test-emails/14542/7
from value of Life(sic) is set as Life in the resulting email
Offending line of code: https://github.com/TryGhost/Ghost/blob/master/core/server/services/bulk-email/index.js#L74
I temp-fixed this by editing the Ghostmailer.js file in the core code. Removed the following (65-74; I removed space formatting for readability):
let fromAddress = message.from;
if (/@localhost$/.test(message.from) || /@ghost.local$/.test(message.from)) {
fromAddress = '[email protected]';
logging.warn(`Rewriting bulk email from address ${message.from} to ${fromAddress}`);
BATCH_SIZE = 2;
}
const blogTitle = settingsCache.get('title');
fromAddress = blogTitle ? `${blogTitle}<${fromAddress}>` : fromAddress;
and replaced with the code below, getting my desired result.
fromAddress = "\"Life(sic)\" <[email protected]>";
Certainly not the cleanest fix but I am not a master coder and don't know how to fix otherwise. I am only sending newsletters at the moment so it serves the purpose, however with every version change I will have to re-edit this code. At least it's only editing one file with version upgrades. Any other ideas?