Search code examples
c#asp.net-mvcasp.net-mvc-3mvcmailer

How to use MVCMailer without breaking my service layer?


I am looking into using MVcMailer to make nicer emails.

However one thing that I am unsure is how to organize the code. I currently have 2 projects. One for mvc and one for my repos and service layers.

my 2nd project has no knowledge of MVC and I would like to keep it that way.

I am thinking that my smtp code would go into a service layer or wrapper and then I would call it up from other service layers when I need to send emails out.

So where does the MVC mailer fit in? Do I generate the body in the controller then pass it to a serivce layer that passes it to my smtp class?


Solution

  • MVCMailer seems to already have support for sending email. If you setup the config correctly it should be able to email the populated MailerViews without additional implementation.

    I am not sure of the role of your second project in you solution but here are two possibilities:

    1. Probably not practical ... Wait for the version with "Email Sending from a Background Process"

    2. Forget about Smtp from your second project and using Http just call a View which in turn would call MVCMailer