Digital Ocean、G Suite、SendGrid、Namecheap

我在让我的新 Discourse 服务器处理电子邮件方面遇到了不少麻烦。

我使用 DigitalOcean 进行托管。那里似乎没有问题。服务器正在运行,我也能够登录。

我使用 G Suite 作为管理员邮箱,但不处理网站邮件。

我使用 Namecheap 进行 DNS/域名注册。

我使用 SendGrid 作为网站的 SMTP 提供商。我尝试了所有能想到的验证组合:使用顶级域名、使用子域名、移除 SendGrid 提供的域名信息并将其输入到 Namecheap 中、将域名添加到 G Suite 的白名单(这甚至有必要吗)?

我可以发送电子邮件。从 SendGrid 可以看到,测试邮件已从 Discourse 发出,但从未成功送达。SendGrid 的错误消息中显示了以下信息:

gmail-smtp-in.l.google.com 接收

被阻止

Gmail 服务器阻止了此消息的送达。虽然我们将不再尝试重新发送此消息,但未来我们将尝试向该地址发送新消息。

您可以查看您所有的 [被阻止地址]

来自 Gmail 服务器的完整响应:

550 5.7.1 由于域名的 DMARC 5.7.1 策略,未通过身份验证的来自 do.c 的电子邮件未被接受。如果这是 5.7.1 合法邮件,请联系 do.c 域名的管理员。请访问 5.7.1 了解 5.7.1 DMARC 计划。m55-v6si4266550qtc.214 - gsmtp

这是否将我的问题严格限定在 SendGrid 和域名验证上,还是另有原因?无论如何,一旦我将他们提供的信息粘贴到 Namecheap 的 DNS 部分,SendGrid 就永远无法完成验证。

As it says, Your dmarc record is not correct.
You can find the correct dmarc value in sendgrid and that should be updated into your dns.
Please correct it or contact sendgrid for assistance.

Just by chance, is it a one-click install app from DO?

@itsbhanusharma, yes. I did the one-click Discourse setup. Everything went very smoothly up until the SMTP setup. I’ve put in a ticket with SendGrid and am waiting for their response.

What is the notification email in your discourse admin? I think that needs to be corrected.

It is currently set at noreply@unconfigured.discourse.org.

When going through the setup wizard I chose for the system to handle mail so the one G Suite account I have to accompany the site info@mydomain.com is not flooded with messages, if I’m even understanding it correctly.

It can’t be @unconfigured.discourse.org in any case.

Please change it to @(your-discourse-domain) or the domain that’s verified with sparkpost first. I hope that’ll fix it.

Also, you may have to tweak your smtp port as DO may be blocking common SMTP ports on your account.

@itsbhanusharma, I made your suggested changes and it worked, although the message did go to my spam folder and is still showing “via SendGrid”. I’m guessing the way to solve that is through domain verification with SendGrid and that will be between me and them.

Exactly. They should have provided you some DNS records to create. Those records take care of the whole verification process.

Great. Thanks so much for the help. Now I’m wondering if I need to go back and undo some of the things I did like whitelisting my G Suite account with SendGrid and stuff like that.

Not immediately, first step that I’d take is to make sure sendgrid is happy with my domain and then I’d test the quality of emails sent using mail-tester.com or similar service.

Once that’s all fixed then only I’d lax any whitelist

As it’s set up now, while going through all the various forums trying to troubleshoot my problem I followed one tutorial that had me go into my G Suite settings and whitelist Digital Ocean, not SendGrid like I said. Because that wasn’t related to my actual problem is it necessary anymore or could it cause any problems in the future?

It actually wasn’t even whitelisting. It was SMTP relay service where I added my droplet IP address.

While it won’t really cause any problems as long as you retain the IP it can possibly cause spam whitelist if you leave the IP and other owner is a notorious spammer.

So it’s okay to remove it. Also, DO is not sending emails from it’s own IP either. Those are sent from sendgrid.

Great. Thanks again for the help.

While I’m able to get emails delivered to people who register for the forum now (albeit in their spam folder), I now am having trouble sending admin emails. When I attempt to make a member of the forum and admin, I get the message saying to check my email. My single G suite email address is info@mydomain.com. SendGrid can never seem to send a message from info@mydomain.com to info@mydomain.com. This is quite a problem because I can’t make anyone else an admin because I can never finish the process. There error I get from SendGrid is:

The mydomain.com server blocked this message from being delivered. While we won’t try to send this message again, we will attempt to send new messages to this address in the future.

You can view all addresses in your Blocks suppression group. Learn more.

Full response from the mydomain.com server:

error dialing remote address: dial tcp 167.89.106.64:0->162.255.119.167:25: i/o timeout

You should check the mail debugging document. The problem is between sendgrid and your mail server that is refusing connections from sendgrid.

I’m using Namecheap, so I had set up all of my SendGrid information CNAME records, but in the “Mail Settings” portion of the Advanced DNS page I didn’t have anything selected. Once I selected Gmail everything began to work. I swear I’d thought I had read something about if you’re setting up SendGrid you don’t need anything the Mail Settings section. Things appear to be working now.