简体   繁体   English

通过 SendGrid C# SMTP 库发送电子邮件未发送到某些域

[英]Sending Emails via SendGrid C# SMTP Library aren't getting delivered to Certain domains

My issue is quite similar to this although there weren't any conclusive facts to resolve mine.我的问题与非常相似,尽管没有任何确凿的事实可以解决我的问题。

Unlike the linked Post, I did the following:与链接的帖子不同,我做了以下事情:

  1. I was able to Authenticate using apikey我能够使用apikey进行身份验证
  2. I am getting a Response.StatusCode as Success after I send the email发送电子邮件后,我收到Response.StatusCode as Success
  3. I am using a WinForms app by using the SendGrid Library installed via Nuget although I am looking at having it as a WebJob in Azure AppService down the line.我正在通过使用通过 Nuget 安装的 SendGrid 库来使用WinForms应用程序,尽管我正在考虑将其作为 Azure AppService 中的 WebJob。
  4. Validated Single Sender verification经验证的单一发件人验证
  5. I was able to send Emails to Gmail, Outlook, and Yahoo recipients.我能够向 Gmail、Outlook 和 Yahoo 收件人发送电子邮件。
  6. HOWEVER, I WAS NOT able to send emails to recipients of a domain (ie. abc.com) where an account of the same domain was used for Registering as my SendGrid account (ie. me@abc.com).但是,我无法向域(即 abc.com)的收件人发送电子邮件,其中使用相同域的帐户注册为我的 SendGrid 帐户(即 me@abc.com)。
  7. I have tried sending emails to mix of recipients ie.我曾尝试向多个收件人发送电子邮件,即。 Gmail and abc.com but only the Gmail recipient is getting the mail Gmail 和 abc.com 但只有 Gmail 收件人收到邮件
  8. I am able to check the logs under Activity and it all said delivered;我可以检查 Activity 下的日志,并且都说已交付; even for recipients of abc.com although none of the recipients of abc.com haven't got it即使对于 abc.com 的接收者,尽管 abc.com 的接收者都没有得到它
  9. I also check in the Quarantine Center of 0365 ( https://security.microsoft.com/ ) but didn't see any messages there.我还检查了 0365 ( https://security.microsoft.com/ ) 的隔离中心,但在那里没有看到任何消息。

The Code I am using to execute the is at the simplest form:我用来执行的代码是最简单的形式:

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

            var apiKey = xxxxxxxx";
            var client = new SendGridClient(apiKey);
            

            var from = new EmailAddress("x1@abc.com");
            var subject = "Sending with Twilio SendGrid to JKSTOCK";
            var to = new EmailAddress("x2@abc.com");
            var cc = new EmailAddress("x3@abc.com");
            var bcc = new EmailAddress("x4@abc.com");
            var plainTextContent = "Test mail sent from SendGrid using C# to ABC.COM";
            var htmlContent = "<strong>and easy to do anywhere, even with C# to ABC.COM</strong>";
            var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
            msg.AddCc(cc);
            msg.AddBcc(bcc);
            var response = await client.SendEmailAsync(msg).ConfigureAwait(false);

            MessageBox.Show($"Status = {response.StatusCode} Success={response.IsSuccessStatusCode} other:{response.Body.ToString()}");

What I am doing wrong here?我在这里做错了什么?

Twilio developer evangelist here. Twilio 开发人员布道者在这里。

It seems likely to me that the mailbox provider you are failing to send to is being more picky with incoming emails than Gmail.在我看来,您未能发送到的邮箱提供商对收到的电子邮件比 Gmail 更挑剔。 You said you have used Single Sender Verification, which is good for testing that you can send emails, but for production use it is better to perform Domain Authentication .您说您使用了单发件人验证,这对于测试您是否可以发送电子邮件很有用,但对于生产用途,最好执行域身份验证

Domain Authentication doesn't just verify that you own the domain and can send from email addresses on the domain, it also sets up SPF (Sender Policy Framework) and DKIM (DomainKeys Identified Mail) which allow for better verification of emails on the part of the mailbox, building more trust and reputation for your sender.域身份验证不仅验证您是否拥有域并可以从域上的电子邮件地址发送,它还设置了SPF(发件人策略框架)DKIM(域密钥识别邮件) ,以便更好地验证电子邮件邮箱,为您的发件人建立更多信任和声誉。 Setting up SPF and DKIM also puts you on the path to enable DMARC (Domain-based Message Authentication, Reporting and Conformance) as well, which can further increase your reputation.设置 SPF 和 DKIM 还可以让您走上启用DMARC(基于域的消息身份验证、报告和一致性)的道路,这可以进一步提高您的声誉。

I would investigate Domain Authentication in order to improve your emails chances of landing in inboxes.我会调查域身份验证,以提高您的电子邮件进入收件箱的机会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM