Reputation: 1961
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
Response.StatusCode
as Success after I send the emailWinForms
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.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("[email protected]");
var subject = "Sending with Twilio SendGrid to JKSTOCK";
var to = new EmailAddress("[email protected]");
var cc = new EmailAddress("[email protected]");
var bcc = new EmailAddress("[email protected]");
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?
Upvotes: 1
Views: 1024
Reputation: 73075
Twilio developer evangelist here.
It seems likely to me that the mailbox provider you are failing to send to is being more picky with incoming emails than 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. 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.
I would investigate Domain Authentication in order to improve your emails chances of landing in inboxes.
Upvotes: 2