Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 293
holiveira Avatar asked Jan 17 '09 23:01

holiveira


People also ask

How do I enable SSL authentication for SMTP connection?

To enable SSL support, set the ALWAUTH parameter to either *LCLRLY or *RELAY using the Change SMTP Attributes (CHGSMTPA) command. If you set the parameter to *RELAY, only e-mails sent from the other SMTP server support the use of SSL.

What version TLS does System Net Mail SmtpClient support?

NET web service to use TLS 1.2.

What is SmtpClient C#?

Allows applications to send email by using the Simple Mail Transfer Protocol (SMTP). The SmtpClient type is obsolete on some platforms and not recommended on others; for more information, see the Remarks section.


1 Answers

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

For more information you can see https://blogs.msdn.microsoft.com/vikas/2008/04/29/bug-asp-net-2-0-passwordrecovery-web-control-cannot-send-emails-to-ssl-enabled-smtp-servers/.

For .NET 4: You can.

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

<configuration>     <system.net>         <mailSettings>             <smtp deliveryMethod=”network”>                 <network host="localhost"                          port="25"                          enableSsl="true"                          defaultCredentials="true" />             </smtp>         </mailSettings>     </system.net> </configuration> 
like image 95
eKek0 Avatar answered Sep 22 '22 12:09

eKek0