SendGrid configuration

If you’re looking for help, please provide information about your environment. If you delete this template and don’t provide any information, your topic will be automatically closed.

If you aren’t running the latest version of Ghost, the first thing we’ll ask you to do is update to the latest version of Ghost.

And

  • How was Ghost installed and configured?
  • What Node version, database, OS & browser are you using? NodeJS v18.17.1 - MySQL, Windows 11, Chrome
  • What errors or information do you see in the console? Failed to load resource: the server responded with a status of 504 () (Container; [2023-09-16 14:26:18] WARN Error sending email: Failed to send email. Reason: Connection timeout. Please check your email settings and resend the invitation.)
  • What steps could someone else take to reproduce the issue you’re having?
    Get this config;
    {
    “url”: “http://localhost:2368”,
    “server”: {
    “port”: 2368,
    “host”: “0.0.0.0”
    },
    “mail”: {
    “transport”: “SMTP”,
    “options”: {
    “service”: “Sendgrid”,
    “host”: “smtp.sendgrid.net”,
    “port”: 587,
    “secure”: true,
    “auth”: {
    “user”: “apikey”,
    “pass”: “SG.MYPRIVATEAPIKEY”
    }
    }
    },
    “logging”: {
    “transports”: [
    “file”,
    “stdout”
    ]
    },
    “process”: “systemd”,
    “paths”: {
    “contentPath”: “/var/lib/ghost/content”
    }
    }

Are you aware that Ghost has different settings for transactional mail and bulk mail?

I presume you were trying to use in grid for the bulk mail. Currently only s Mailgun is supported.

The settings you posted would only be used for welcome emails, forgot password and other one-off emails.

Yeah, but when inviting team members its is using the transactional version right?

That’s correct. I’m not spotting anything obviously wrong with these settings. You may want to check that your api key is correct.

Yeah, i have also set again te api key.

It is as user: “apiKey” and password than only the api key right?

Also in the SendGrid settings i dont see anything that there where any incomming requests.

This example shows apikey, but you have apiKey (note the difference in capitalization). I’m not sure which is correct, or if sendgrid cares about capitalization of that field - you’d need to check sendgrid’s docs.

If you haven’t already, check your ghost logs - there might be more detail about the problem. Also check that you aren’t firewalling this port, and that your web host doesn’t block it.

1 Like

Looks good to me, tbh

docker run --rm -it --name ghost -e mail__transport=SMTP  \
        -e mail__options__auth__user="apikey" \
        -e mail__options__auth__pass="YOUR_SENDGRID_API_KEY" \
        -e mail__options__host="smtp.sendgrid.net" \
        -e mail__options__port=587 \
        -e mail__options__secureConnection=true \
        -e url=https://blog.zanshindojo.org -p 2368:2368 -v ghost-data:/var/lib/ghost/content ghost

in this example you can see that the user is apiKey and password the API-key.

What i can try is to give the credentials directly in the env of the container…

Result:
[2023-09-16 18:01:05] WARN Error sending email: Failed to send email. Reason: Connection timeout. Please check your email settings and resend the invitation.

I have just switched to Mailgun but, that does also not work…

Can you check with your host if outbound 587 is enabled? I think I’ve seen a few self hosters mention that they had to reach out to their cloud provider to enable the port.

2 Likes

Also, your Docker networking needs to set allow the outgoing networking requests if it’s not already.

Your config seems fine. check if your account IP Access management (“Settings” > “IP Access Management”). If it’s turned on, whitelist your server IP.

1 Like

I have contacted my service provider and they said that the port was blocked!

Thanks for your time everyone! :slight_smile:

2 Likes