smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
582 stars 178 forks source link

Reading Config Values from appSettings #112

Closed amjadkhan closed 11 years ago

amjadkhan commented 11 years ago

Is there anyway to get MVCMailer to read smtp settings from the appSettings section of the config file rather than the smtp node? My host only injects values into the appSettings section of the config file.

smsohan commented 11 years ago

You can use GetSmtpClient of your MvcMailMessage object and set custom properties from appSettings.

amjadkhan commented 11 years ago

? The Populate(Action [MvcMailMessage] action) method on MailerBase returns an MvcMailMessage. How do I use GetSmtpClient to set smtp settings ? GetSmtpClient returns ISmtpClient which only has Send methods? Can you please provide an example of how to read and assign appSettings such as host, port, username and password. Thanks

smsohan commented 11 years ago

Cast it to SmtpClientWrapper and use the innerSmtpClient property. Alternatively, create your own implementation of ISmtpClient and pass an instance of it to the Send method. Sorry, I can't share a code now.


Sent from my iPhone Sohan SM

On Sep 23, 2013, at 4:41 PM, Amjad Khan notifications@github.com wrote:

? The Populate(Action action) method on MailerBase returns an MvcMailMessage. How do I use GetSmtpClient to set smtp settings ? GetSmtpClient returns ISmtpClient which only has Send methods? Can you please provide an example of how to read and assign appSettings such as host, port, username and password. Thanks

— Reply to this email directly or view it on GitHubhttps://github.com/smsohan/MvcMailer/issues/112#issuecomment-24961409 .