Demonstrates how to send SMTP e-mail with SendGrid and Mailkit. Uses Configuration, UserSecrets, and Serilog as well.
⚠ Warning: this sample is provided as is. There will likely be no (security) updates, and you should consider this example frozen in time.
This example is based off the SendGrid (Twillio) blog on the same subject. The condensed version of all steps is:
- Create a Sendgrid account
- Complete onboarding (a "Single Sender Domain" account is good enough)
- Create an API key with permissions: "Restricted Access" and at least "Mail Send" Full Access
To use this sample:
- Clone the repository;
- Create UserSecrets for the csproj file (or change the
appsettings.json
but be sure not to commit those changes!!), duplicate the "SendGrid" section in its entirety and use your own settings; - Run the application;
That's it!