andrewdavey / postal

Email sending for asp.net mvc using the view engine system to render emails.
http://aboutcode.net/postal
MIT License
536 stars 168 forks source link

Unable to change mailSettings on a per email basis #121

Open ngudritz opened 9 years ago

ngudritz commented 9 years ago

I have default smtp settings configured in the web.config, but we need to be able to change the sender credentials based on the type of email going out. It looks like no matter what, Postal uses what's in the web.config without a way of overriding it. Is this true or is there another way to the smtp credentials for a single email at runtime?

tiesont commented 9 years ago

It doesn't look like a single email can be overridden, but you can override the SMTP client creation: https://github.com/andrewdavey/postal/blob/master/src/Postal/EmailService.cs

That would require you to create a new instance of EmailService every time you wanted to send an email, rather than injecting an instance in your object's constructor.

I can see something like this being useful in a handful of projects, so if you can elaborate on your use-case(s) a bit, I could take a stab at something a little more "friendly".

iamgurdip commented 8 years ago

It would be great if the SMTP could be configured using code as well. A use case is that i do not want to store passwords in the Web.config, b/c we are required to store the credentials in a key vault.