Configure SMTP programmatically

90 views
Skip to first unread message

Majo Mikula

unread,
Jan 23, 2017, 2:13:33 AM1/23/17
to ELMAH
Is it possible to configure SMTP programamatically? I need it when sending log failure to one SMTP I want to send it over other SMTP.

Thanks

Atif Aziz

unread,
Jan 24, 2017, 2:20:27 AM1/24/17
to el...@googlegroups.com
Programmatically, you can do anything. :)

Your best would be to either subclass ErrorMailModule and plug-in your custom logic (you will then have to register your subclass instead in the web.config) in the relevant overrides or hook into the events of the same class and send the email yourself.

The following blog shows an example of how to use the events for some customisation although it's not exactly your case of changing SMTP settings:

You might also want to checkout the ELMAH Bootstrapper project that customises ELMAH considerably to make it friendlier to use, including the mailing module. One of the things that the Bootstrapper adds is the ability to pull out the SMTP configuration that would be used to send the error e-mail. You can then use and tweak those setting to send the e-mail yourself when, for example, the Mailing event fires (if you do that, you should set the ShouldNotSend property to true if you don't want a duplicate). What it doesn't allow, unfortunately, is changing the settings per message and let ELMAH still send out the e-mail.

- Atif 


On Sun, Jan 22, 2017 at 9:53 AM, Majo Mikula <majc...@gmail.com> wrote:
Is it possible to configure SMTP programamatically? I need it when sending log failure to one SMTP I want to send it over other SMTP.

Thanks

--
You received this message because you are subscribed to the Google Groups "ELMAH" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elmah+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages