holiveira holiveira - 1 year ago 214
ASP.NET (C#) Question

How to enable SSL for SmtpClient in Web.config

Is there a way to set the EnableSSL from the web.config?

I could set this property in code, but that wouldn't work for the Simple Mail Web Event and other classes that uses the default Smtp Server. Any ideas?

Answer Source

For .NET 3 and earlier: You can't. You have to manage it by hand.

For more information you can see http://robertseder.spaces.live.com/blog/cns!587F478B9240C01E!270.entry.

For .NET 4: You can.

See http://theoldsewingfactory.com/2011/01/06/enable-ssl-in-web-config-for-smtpclient/

            <smtp deliveryMethod=”network”>
                <network host="localhost"
                         defaultCredentials="true" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download