This sample shows a couple of examples of how you can use the Cofoundry mail abstraction to send emails, including:
- Creating custom mail templates
- Sending mail with
IMailService
- Customizing email notifications for admin panel accounts
For more information on using email in Cofoundry, see the mail docs.
- Create a database named 'Cofoundry.Samples.Mail' and check the Cofoundry connection string in the config file is correct for your SQL Server instance
- Run the website and navigate to "/admin", which will display the setup screen
- Enter an application name and setup your user account. Submit the form to complete the site setup.
The sample use the default Cofoundry mail implementation, which simply writes out the rendered mail content to text files in the "App_Data/Email" folder.
This is good for testing, but for production you'll want to install a mail plugin that is compatible with your mail host.
Refer to the mail docs for more details.
The HomeController
shows how to build a simple email notification from a contact request form using a custom template. The template files can be found in the "Cofoundry/MailTemplates/ContactRequest" folder.
The AdminMailTemplateBuilder
class and the templates in the "Cofoundry/MailTemplates/Admin" folder show several different ways you can customize the admin email notifications.