In an ASP.NET MVC application, how should the sending of emails be handled? I've been thinking about this, and I really like the idea of handling it in an MVC-oriented way (it is an MVC application, after all.)
What I mean is that the email that gets delivered to the user is really just a view that should have a model passed to it. This raises some questions: How should we deliver views to both the requesting browser and an SMTP server at the same time, when an action is executed? Does the framework have any facilities to support this? If not, is there some 3rd party release/guidance for this sort of functionality?
The alternatives to treating email sending in an MVC way are:
- Email sending code shows up in the controller's action methods.
- Email sending is a behavior of the Model objects.
How are you handling the sending of emails in your ASP.NET MVC applications? What do you think about an MVC-oriented approach?