[英]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:与链接的帖子不同,我做了以下事情:
apikey
我能够使用apikey
进行身份验证Response.StatusCode
as Success after I send the email发送电子邮件后,我收到Response.StatusCode
as SuccessWinForms
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。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.