Я получаю IsSuccessStatusCode true в ответ на вызов sendEmailAsync() и
в моя панель действий SendGrid показывает, что все они доставлены, поэтому я знаю, что они отправляются и получают ответ ok() от почтового сервера.
Вопрос. Похоже, что в сети или у поставщиков услуг электронной почты что-то происходит с фильтрацией, спамом и т. д. Откуда мне знать? Единственное, что я нашел, это ссылка для устранения неполадок SendGrid.
Вот мой код.
Код: Выделить всё
dynamic templateData = new JObject();
templateData.name = "Test";
templateData.text = "Testing";
templateData.buttonText = "Test";
templateData.buttonUrl = "Test";
// works!
var emails = new string[] {"[email protected]"};
// doesn't work!
var emails = new string[] {"[email protected]", "[email protected]", "[email protected]"};
// send email
_emailService.ExecuteTemplate(emails, "Test Subject" templateData);
// function
public async Task ExecuteTemplate(string[] toEmailAddresses, string subject, dynamic templateData) {
var client = new SendGridClient(sendGridOptions.SendGridKey);
SendGridMessage sendGridMessage = new SendGridMessage() {
From = new EmailAddress(_config["SendGrid:Server"], "Yogabandy"),
TemplateId = _config["SendGrid:TemplateId"]
};
templateData.subject = subject;
for (int i = 0; i < toEmailAddresses.Length; i++) {
sendGridMessage.AddTo(new EmailAddress(toEmailAddresses[i]), i);
sendGridMessage.SetTemplateData(templateData, i);
}
sendGridMessage.SetClickTracking(false, false);
sendGridMessage.SetOpenTracking(false);
sendGridMessage.SetGoogleAnalytics(false);
sendGridMessage.SetSubscriptionTracking(false);
var response = await client.SendEmailAsync(sendGridMessage);
if (response.IsSuccessStatusCode) {
_logger.LogInformation("Email queued");
} else {
_logger.LogError("Email not queued. Satus Code: " + response.StatusCode);
}
return response;
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... t-can-succ