sendgridelmah

Elmah sending error mails with Sendgrid API Keys


Normally I use the SMTP settings in my web.config file with UN/PW to my Sendgrid account to send elmah error emails. But, with two factor authentication I don't believe sendgrid allows sending emails with basic authentication. Does, anyone know if there is a way to use the API key to authenticate the Elmah error emails?

  <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>

Thank you!


Solution

  • SendGrid doesn't offer auth through basic authentication when two-factor is enabled. From their documentation:

    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.

    I believe you might have a chance to get this working, though. Try setting the username in config to apikey and password to an API key you generate through SendGrid. Possible solution found here: https://sendgrid.com/docs/API_Reference/SMTP_API/integrating_with_the_smtp_api.html