Ghost: "'from' parameter is not a valid address" error when sending members emails

Created on 23 Apr 2020  路  3Comments  路  Source: TryGhost/Ghost

Issue Summary

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

To Reproduce

  1. Change your site title to @test
  2. Ensure members is enabled and Mailgun configured
  3. Create a draft post and choose "Send test email" from the email newsletter settings

Email should be sent but instead you get an error.

Technical details:

  • Ghost Version: 3.14.3
bug members / mega

All 3 comments

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

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?

Was this page helpful?
0 / 5 - 0 ratings