views:

3323

answers:

6

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?

A: 

i m getting a configuration error as "Unrecognized attribute 'enableSsl'. Note that attribute names are case-sensitive."

A: 

I have searched almost everywhere for this. But it seems there is no way we can configure EnableSsl Property in web.config. Have a look of this - https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=281277

+4  A: 

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.

eKek0
+1  A: 

Ah, there is a way to do it for the 'forgot password' built in .net login controls though.

See http://blogs.msdn.com/vikas/archive/2008/04/29/bug-asp-net-2-0-passwordrecovery-web-control-cannot-send-emails-to-ssl-enabled-smtp-servers.aspx

Ryan

Ryan ONeill
+2  A: 

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.

Miguel Madero
A: 

Just extend the class and set EnableSsl = true and use that class.

Kevin Korb