Discourse and SendGrid not playing nicely

First, this is the main post for troubleshooting email. I’ve followed it but to no avail, unless I’ve still missed something.

I appreciate from many hours trying to fix this problem now that setting up email can prove to be a challenge to the uninitiated!

Here’s my DNS:

The SendGrid test works perfectly. When I use that to send an email to mail-tester.com, I get full marks. Yippee!

But will Discourse send a confirmation email to my personal gmail account. No! Nothing appears in the SendGrid logs either. Discourse doctor confirms I have a problem, but isn’t explicit.

One last thing, I did add an egress firewall rule on my Google Cloud instance for tcp at 2525.

Thanks in advance to anyone with the patience to fix this … a community self-help forum for Covid-19 at https://cooperating-in-chiswick.uk

1 Like

Last time I used SendGrid (a few years ago), the official doc was incorrect and I had to remove my domain name from the CNAME records. So you might want to try this:

em92			CNAME     300           ...
s1._domainkey	CNAME     300           ...
s2._domainkey	CNAME     300           ...
1 Like

Ah OK will try that now. Thanks.

Although how come it works using the SendGrid test?

1 Like

What does discourse-doctor say about the mail test?

1 Like

Testing sending to ***@gmail.com using smtp.sendgrid.net:2525.



535 Authentication failed: Bad username / password


The most likely problem is that your SMTP username and/or Password is incorrect.
Check them and try again.

Replacing: Sending mail to

I have checked and checked and checked the PASSWORD (API key without quote marks).

should the email addresses for LETSENCRYPT_ACCOUNT_EMAIL and DISCOURSE_DB_PASSWORD be in single quotes?

Just found this topic which clearly has the LETSENCRYPT_ACCOUNT_EMAIL in single quotes, which I did not have. Added the single quotes and relaunching the application. Fingers crossed.

If you use ./discourse-setup and follow the prompts they will be formatted correctly for you, assuming you don’t add any extra " ’ [ { (

1 Like

I did. Thanks @Stephen. App still rebuilding but now I’m not holding out so much hope.

… Rebuilt. No difference.

trying @syl’s recommendation now — :sunglasses:

Nope. Now I remember (having gone there again), that this is the form:

Screenshot 2020-03-23 at 21.37.07

So that’s what the problem is, or at least one of the problems.

DNS stuff might be broken too, but you definitely need to figure out the username password bit first.

I think with sendgrid you use your API key as the password? discourse-setup should know what username to use.

1 Like

Thanks @pfaffman but I don’t know how else to paste the things in to app.yml !!

Here’s a screenshot with the SendGrid password replaced to keep things secure:

Screenshot 2020-03-23 at 21.40.40

I will set up a new API name and password just in case I made an error copying and pasting the first key.

But could that really be the problem if SendGrid’s own test works perfectly on my instance?

Did you not use discourse-setup?

From: Integrating with the SMTP API - SendGrid Documentation | SendGrid

And it really means that your username is apikey. It’s not “apikey” standing in for something else, it’s those exact letters. apikey


My immediate response was … YES!

My second response was … CR*P!

Screenshot 2020-03-23 at 21.48.03

This SendGrid screenshot shows a column of bold text with the column heading of NAME. But I think we’re looking at the little text right underneath, right? (Feeling equal rage and delight … odd feeling indeed.) On your confirmation, I will change and relaunch and wait with baited breath.

Oh no, hang on, you’re saying:


1 Like

Did you click on the sendgrid link I gave you and read their directions?

You want that text underneath (after you delete both of those API keys and generate a new one) to be the SMTP_PASSWORD. And the SMTP_USERNAME to be 'apikey, which is what discourse-setup` will suggest if you use a sendgrind SMTP server.

1 Like

Thanks for your patience.

I did read it, and I’ve read it again. SendGrid offers up a private key and only displays it once. This was not shown in the screenshot. As for the “API Key ID”, mousing over it produces the message:


Screenshot 2020-03-23 at 22.14.15

Thank you @syl @Stephen @helmi and @pfaffman :pray:

Onwards and upwards.


Good to hear you got it solved \o/