SendGrid offers a powerful and full-featured solution to email delivery. The service is highly scalable and extremely easy to provision in Azure. SendGrid offers several pricing plans including one ideal for a for fun solution like BrowserPower: FREE. With the free plan, the service will provision up to 25,000 emails/month. For scenarios of providing email for registration and forgotten password retrieval, BrowserPower should be well under that limit!
public
class
EmailSender : IEmailSender
{
EmailSender(IOptions<AuthMessageSenderOptions> optionsAccessor)
Options = optionsAccessor.Value;
}
AuthMessageSenderOptions Options {
get
; }
//set only via Secret Manager
Task SendEmailAsync(
string
email,
subject,
message)
return
Execute(Options.SendGridKey, subject, message, email);
Task Execute(
apiKey,
message,
email)
var client =
new
SendGridClient(apiKey);
var msg =
SendGridMessage()
// should be a domain other than yahoo.com, outlook.com, hotmail.com, gmail.com
From =
EmailAddress(
"donotreply@somewhere.com"
,
"IndieGamesLab"
),
Subject = subject,
PlainTextContent = message,
HtmlContent = message
};
msg.AddTo(
EmailAddress(email));
client.SendEmailAsync(msg);