问题
I'm setting up Elmah emails and I don't want to put my email account credentials in web.config.
I'm deploying on Azure and therefore would like to look up the credentials from Azure app settings in code on app startup.
Is there a way to configure Elmah emails declaratively in code rather than using the <errorMail> tag?
回答1:
The best way to do this is by overriding the SendMail
method of Elmah's ErrorMailModule
, as suggested by Atif Aziz in this discussion on Google Groups.
I've given more details in this answer.
回答2:
You could trap the Elmah Mailing event and substitute your email addresses.
http://scottonwriting.net/sowblog/archive/2011/01/06/customizing-elmah-s-error-emails.aspx
来源:https://stackoverflow.com/questions/21484728/configure-elmah-email-settings-in-code-rather-than-config