Closed kenlewisjr closed 14 years ago
Hi Ken, I looked into this and it appears that you really should be setting the EnableSsl parameter when constructing the SmtpClient itself (prior to instantiating the wrapper). For instance (in UserAdministrationController.cs):
new SmtpClientProxy(new SmtpClient{EnableSsl = true}))
Ideally you would refactor the injection of this dependency out of the controller and into your IoC container, and configure the SmtpClient correctly there. Does that make sense?
Hi Troy,
Thanks for looking into this. You're right, I shouldn't set it where I did. In fact, as I researched this I discovered that I can set "enableSsl" in the web.config file in the "smtp/network" element (along with host, port, etc.). This achieves the goal of having the SmtpClient properly configured at construction and requires no change to your original code.
Now, about IoC: I'm pretty new to IoC though I am using it for my repositories. Would you still recommend it if I am not changing your code?
Thanks again,
Ken
It is up to you. If you aren't planning to make any changes to the UserAdministrationController then maybe it wouldn't be worthwhile. That controller was definitely built with the idea that you customize it for your own needs though, so if you ever do get around to customizing it I would recommend setting it to use IoC at that time.
I'm going to go ahead and close this issue (since it isn't an actual bug or missing feature), but feel free to email me at troygoode@gmail.com if you want to chat about it further.
I added an "enableSsl" parameter to the SmtpClientProxy's Send Method. Doing this allows me to use Gmail as my SMTP server, which eliminates the need to configure the IIS SMTP server on my different machines (i.e., development, production). In fact, no configuration changes are required at all for development or production use.
I'm passing this along as a suggested change and as an idea in case anyone else finds this approach helpful.
Ken