I am integrating a mailing list into an existing CMS in asp.net MVC.
I need to send a confirmation email to the subscriber. Where should I send it from, the controller, Or the service layer?
Clarification: I would definitely create a separate service method called SendConfirmationEmail(). The question is who calls it the controller handling the registration form or the service that added the pending request to the DB?
Obviously I can send it from both but which is proper MVC?
I guess the standard approach is to have an email service that is injected into your controller and the controller only invokes the service operation like _emailService.Enqueue(myMessage).
Some of the benefits are:
email functionality in another
controller / action
unit tests so your tests don’t rely
on an SMTP server