Skip to content

E-Mails

Emails are send out with SendGrid and created with a razor templating engine.
FluentEmail has integrations with all common email services and allows some really neat syntactic sugar.

Both are very easily replaceable with whatever you want to use for creating or sending emails.

Libraries and Tools

Example

fluentEmail
.To(req.Email)
.Subject("Password reset")
.UsingTemplateFromFile(@"Infra\EmailTemplates\PasswordResetEmail.cshtml", new PasswordResetEmail
{
PasswordResetUrl = myUrl,
Name = $"{user.FirstName} {user.LastName}",
SupportUrl = "https://www.breakneck.com/support"
}
);
await fluentEmail.SendAsync();
<p>
Hi @Model.Name, <br/>
There was a request to change your password!
</p>
<p>If you did not make this request then please ignore this email.</p>
<p>Otherwise, please click this link to change your password: <a href="@Model.PasswordResetUrl">@Model.PasswordResetUrl</a></p>
<p>If you did not request a password reset, please ignore this email or <a href="@Model.SupportUrl">contact support</a> if you have questions.</p>

This is typesafe if you’re using .cshtml and a model.
Or you can use an anonymous object new() {someProp: 52} as the second argument in FluentEmail.