Set SMTP Settings on Tenant via code

Topics: Writing modules
Mar 21, 2014 at 6:44 PM
Edited Mar 21, 2014 at 6:58 PM
In my auto-provision module for 1.x, I'd like to be able to set the tenant's SMTP configuration (email, server, port, ssl, username, password) via code when I setup the tenant.

Any ideas on the best way to approach that? Can I edit the SmtpSettingsPart directly? Am I better off trying to write it to the web.config and if I do that, which web.config do I write it to so that all tenants can access it?

Thanks for any suggestions.
Mar 21, 2014 at 11:29 PM
In 1.x there is a new feature which lets you write the smtp settings in the web.config file, using the default section. If present, the values will be used, and you can still overload them per tenant, if you look at the settings page you will see the values from the web.config as placeholders.
Marked as answer by psenechal on 3/21/2014 at 4:57 PM
Mar 21, 2014 at 11:57 PM
Thanks Sebastien...I added them to the web.config and they are indeed showing up in the Email Settings page. Even though the options for enableSSL and the credentials (username) aren't appearing on the Settings page, I did a test and they are being picked up in the web.config and passed to my mail host. I even tested it from the tenant and it successfully used the same settings. Brilliant!
Mar 22, 2014 at 1:04 AM
I am thinking about more stuff like this to provide default values cross tenants. On case by case.