Elmah 使用 Sendgrid API 键发送错误邮件

Elmah sending error mails with Sendgrid API Keys

通常我使用 web.config 文件中的 SMTP 设置和 UN/PW 到我的 Sendgrid 帐户来发送 elmah 错误电子邮件。但是,通过双重身份验证,我认为 sendgrid 不允许发送具有基本身份验证的电子邮件。有没有人知道是否有办法使用 API 密钥来验证 Elmah 错误电子邮件?

  <elmah>
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="DefaultConnection" />
    <errorMail from="error@domain.com" to="email@gmail.com" subject="Exception (test)" smtpServer="smtp.sendgrid.net" smtpPort="587" userName="username" password="password" async="true" />
    <security allowRemoteAccess="true" />
  </elmah>

谢谢!

启用双因素后,SendGrid 不通过基本身份验证提供身份验证。来自他们的文档:

SendGrid no longer accepts Basic authentication (username and password) for API calls when two-factor authentication is enabled for a user. You can now only use two-factor authentication if you are authenticating with an API key. For more information, see Authentication.

不过,我相信您可能有机会让它发挥作用。尝试将配置中的用户名设置为 apikey,将密码设置为通过 SendGrid 生成的 API 密钥。在这里找到可能的解决方案:https://sendgrid.com/docs/API_Reference/SMTP_API/integrating_with_the_smtp_api.html