Custom From Email address

Can’t use a custom domain for the member from address

Reference https://github.com/TryGhost/Ghost/blob/master/core/server/services/members/api.js

line 206 - 224

transporter: {
                sendMail(message) {
                    if (process.env.NODE_ENV !== 'production') {
                        common.logging.warn(message.text);
                    }
                    let msg = Object.assign({
                        subject: 'Signin',
                        forceTextContent: true
                    }, message);
                    const subscriptionSettings = settingsCache.get('members_subscription_settings');

                    if (subscriptionSettings && subscriptionSettings.fromAddress) {
                        let from = `${subscriptionSettings.fromAddress}@${getDomain()}`;
                        msg = Object.assign({from: from}, msg);
                    }

                    return ghostMailer.send(msg);
                }
            },

The from address is set via the database and automatically append the domain. Whereas we have a mail setting in the config which would be better or at least we should remove the get domain part

The issue

We have the blog on one domain and we use a different email domain for sending emails. However, currently, you can’t change the domain for membership, only before the @

github link

this was raised on github but apparently this isn’t a bug which seems strange as you can change other mail from address

3 Likes

I have a similar issue. Ghost does some funny magic where my email ends up as ghost@sub.domain.tld… while the blog is hosted as a subdomain that doesn’t mean you would have a mailserver for sub.domain.tld.

1 Like

This is the issue I’ve found. It uses the blood URL, you cant even override it like rest of ghost mail system with config file.

I suggest using mail.from field in the config and parse out the domain. I’m fine using “ghost@domain.tld” since it’s enough to create an email alias. I’m not fine having dedicated an SMTP account just to send stuff or use another mail provider.

That was my thinking. I’ll try and throw a PR in iver next couple of days and see if their accept it. Fed up using custom solution for this

I got mine set up, but through the process I had to go and “learn” nodemailer, simplesmtp, directmailer on the node side. Then I messed about in postfix on my server (DigitalOcean managed with Serverpilot so I have to be mindfull on where I put my configs or they get overwritten.)

I have a crazy setup:

    /                   Main Ghost blog on port 2368
    /subfolder1         Second Ghost blog on port 2369
    /subfolder2         Wordpress blog (Job board, don't think you can do it in Ghost... yet)
    /subfolder3         Second Wordpress blog (this is to mock about with themes, without bloating Wp)

And I want emails on at least 3 of them, mostly to monitor 404’s (or have some funny guy DDOS my mail server).

But while I was mocking about my mail server refused connections for a while. (I was doing foul things to it).

Two things I can think of that got this working where:

  "mail": {
    "from": "myemail@domain.tld",
    "transport": "DIRECT",
    "options": {}
  },

And while I was looking for a way to create a SMTP account (which I was’t because I’m maxed out for my priceplan) I added “ghost@domain.tld” as an email alias.

Currently, it uses fromaddress i think from the database (just confirming that now) then appends the domain. But i do believe this mail setting should be altered.

Personally i think adding a domain address would be a good idea. Then we can have a membership config that overrides the from?

I’ve put in a solution but not sure if it’s the best option. Its basically adding another property to mail config.

@Jordan-Hall thanks for the proposal and code contribution. Getting back to this just now as the team had other priorities at the end of the year and now seems like a good time to think this through properly :slight_smile:

The proposed solution of having a custom domain seems like a valid way to go. Something I’d consider as well is separating this domain configuration into “general” and “members” specific only :thinking: Instead of messing with a general domain settings, we then could have a separate fromDomain similar to fromAddress setting for members’ emails. We then could postpone doing changes in the general config till the moment when we work on migration from old Nodemailer 0.7.

Ghost does some funny magic where my email ends up as ghost@sub.domain.tld… while the blog is hosted as a subdomain that doesn’t mean you would have a mailserver for sub.domain.tld .

Valid point :arrow_up:

@Kevin @fabien would be good to hear your opinions on this

We had an internal discussion about this feature and decided to follow our usual process when introducing config changes like this one. The change has wider ramifications and we’d have to look into alternative ways to allow defining custom email domains as well as some additional parameters like reply-to.

We are tracking the issue and will make sure to update this thread/GH issue once there is more info :wink:

1 Like

Perfect thank you. I only thrown the code together to get it working, and was a tool only as a suggestion. Looking forward to the solution :slight_smile:

I’ve only seen this thread now.

Linking here that I had shared my 2cents on subdomains under the Ideas tag:

I’m guessing this is my issue. I setup my site as www.domain.com so it forces the email to be ‘something’ @ 'www.domain.com. :thinking:

Yes this will be the issue.

Seems like a rather big issue. I guess I was supposed to setup my site without a subdomain.

Ugh, same issue. Running my blog under blog.mydomain.com and now the from email shows as noreply@blog.mydomain.com.

Really annoying, is there any way around this?

Not really a solution but look at the abandon PR i put in place. Its the code ive been using

Has there been any progress on this?
The inability to send members an email from my actual address (name@website.com) rather than the site’s sub domain (name@blog.website.com) make Ghost completely unusable for me.

1 Like

I was just about to move my subscribers over from Substack (my site runs on Ghost but my newsletter has been running on Substack) and I’m not much of a coder so the above doesn’t make a lot of sense to me. On every email I send, I encourage my readers to hit “reply” and share their thoughts and feedback. So until there’s a user-friendly way to change the email address my Ghost posts send from, I guess I’m staying put on Substack, where this functionality is standard.

1 Like