I have code that relies heavily on email notification. In my web.config I am able to specify an smtp server like this:
<system.net>
<mailSettings>
<smtp from="myaccount@mydomain.com">
<network host="mail.mydomain.com" port="25" userName="myusername" password="mypassword" defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>
This is acceptable, but I would like to implement 2 or 3 exchange servers here in the event that (for what ever reason) smtp server 1 goes offline, I need a backup option.
Is there any quick / built in way to achieve this fail safe in .net, or is there a trusted manual way to implement this. My existing send mesage code looks like this (but watered down):
MailMessage message = new MailMessage();
SmtpClient client = new SmtpClient();
client.Send(message);
Notice its pulling the host directly from the configuration.
Any ideas what is best practice here for this scenario?
and configure the local SMTP transport to relay to your rendundant servers.
that way you won’t loose emails because of transient network problems (the local MTA will just hold on to them).