【发布时间】:2016-12-27 10:59:46
【问题描述】:
我正在使用最新的 SendGrid .NET 包 (8.0.3) 从我的 ASP.NET Core Web 应用程序发送电子邮件:
public Task SendEmailAsync(string email, string subject, string message)
{
return Send(email, subject, message);
}
async Task Send(string email, string subject, string message)
{
dynamic sg = new SendGridAPIClient(_apiKey);
var from = new Email("noreply@my.domain", "My Name");
var to = new Email(email);
var content = new Content("text/html", message);
var mail = new Mail(from, subject, to, content);
await sg.client.mail.send.post(requestBody: mail.Get());
}
它在本地工作,但在 Azure 应用服务实例上运行,邮件无法通过。
代码运行良好,没有任何异常,所以我几乎没有什么可使用的,但我认为这可能是某种防火墙问题。
有没有人遇到过类似的问题?我该如何调试呢?
【问题讨论】:
-
您的 SendGrid 帐户是否有任何 IP 限制? sendgrid.com/docs/User_Guide/Settings/ip_access_management.html
-
不,我没有 IP 限制。查看尝试访问的列表,Azure 的最后一次尝试似乎是在三个月前,因此很明显,调用 SendGrid 的尝试在两者之间的某个地方被阻止了。
标签: c# azure sendgrid asp.net-core-1.0