Email Service

We have implemented a zero-configuration Email service that you can use throughout your application whenever you need to send email. The service is already being used by the system. The system supports three providers: Smpt, MailGun and SendGrid. We have partnered with MailGun, who is offering our customers a discount on their services. Please see the Downloads page for more details.

In addition to three providers to choose from, we have also built an email templating system that you can use to write your email templates in Razor pages and then reuse them over and over again to send email. And because we are using Razor, your templates can contain dynamic content.

Please note that if you have Email based Two-Factor authentication enabled, you need to have at least one Email provider configured, otherwise your application will fail when you start it.

Providers

To enable sending of email using an Smtp server, fill out the corresponding section in ServiceConfiguration.Email.Smtp. Using the Smtp provider works well for small websites that do not need to send a lot of email. A lot of Smtp providers set daily caps on the number of emails you can send out. If Smtp is configured, it will take precedence over MailGun and SendGrid if they are also in the configuration.

To enable sending of email using MailGun, fill out the corresponding section in ServiceConfiguration.Email.MailGun. You first need an account, which is free to create.

To enable sending of email using SendGrid, fill out the corresponding section in ServiceConfiguration.Email.SendGrid. You first need an account, which is free to create.

Email Templates

Creating a new email template is a breeze. If you look in Resources\Templates\Emails, you will see there are already some system templates there. We highly recommend you customize these according to your branding needs before you go to Production. There are a number of free html email templates out there. When editing the system templates, be mindful of the Razor syntax present in the files and use the same models in your new templates, otherwise things like email confirmation and password reset will no longer work properly.

To create a new template, create a new folder of it in Resources\Templates\Emails (or use your own location) and create two templates, one for the plain text email and another for the html email. Right click on both of this files and select Properties. Select Copy if newer for Copy to Output Directory. If you miss this step, your template will not be published to Azure. Also create your model class if your template has dynamic content. Then, open IEmailService and add a new descriptive function for your new email. Implement this new function in FluentEmailService, using the existing code as a template. Now you are ready to inject IEmailService into any page or Controller method and call the new function to send your email.

Please note that due to certain Razor engine limitations, if you are using dynamic content in your email templates, it must all come from the model. Certain constructs such as @Html.Raw and even calling primitives like @DateTime.Now will not work. An alternative is to simply create a new model property that returns whatever data you need.

Table of Contents



An error has occurred. This application may no longer respond until reloaded. Reload 🗙