Initialize SMTP settings for ELMAH through code
The ErrorMailModule has a very simple implementation. During the Init method, it reads the configuration section to get some basic settings like the sender ...
You can configure elmah to post the error report to an HTML address. See this article.
When you set it to post to that address, you can have whatever back end you want catch it and send the email for you.
You mentioned you're using MVC, so you could have elmah post to a controller action that would then send the email, using the SMTP settings from your library project since you'd have access to the references there.
The application includes:
- ASP .NET MVC web app
- Background Service
- Library project
The web app and background service projects use the library project to send emails. SMTP settings are included in a config file in the library project itself.
In this scenario, is there a way to bind ELMAH to pick up SMTP settings from the library project? Perhaps if there's a way to configure ELMAH through code (during Application_Start), it would help achieve what's intended.
Guidance much appreciated.
Click Here to Visit