ASP.NET Core Identity: Use IEmailSender without SendGrid

ASP.NET Core Identity offers you a little interface called IEmailSender to wire up your own logic to send emails for account confirmation and password recovery. The official tutorial at Microsoft uses SendGrid for those emails. While this service has certainly its place, we do not want to change our email infrastructure just because we only can find tutorials for SendGrid.

It took us a little bit of research to find the package in which ASP.NET Core defines IEmailSender: Microsoft.AspNetCore.Identity.UI. You can install it with this command into your project:

That is all it takes to get the IEmailSender interface. As long as your email sending class implements its SendEmailAsync() method, everything in ASP.NET Core Identity will work as expected. But be aware that Microsoft can change the code in that package without any prior notice. Therefore, make sure you have a good test suite to detect those changes quickly.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.