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?
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?
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.
Ah, there is a way to do it for the 'forgot password' built in .net login controls though.
Ryan
I have a dirty workaround (until .NET 4.0 comes out). Instead of changin my code it relies on the used port to determine if SSL is required or not. var client = new SmtpClient(); client.EnableSsl = client.Port == 587 || client.Port == 465; // This could also work //client.EnableSsl = client.Port != 25;
I said it was a dirty hack, but it working fine for the different configurations that we encounter.
Just extend the class and set EnableSsl = true and use that class.