Asp.net
如何在 Web.config 中為 SmtpClient 啟用 SSL
有沒有辦法從 web.config 設置 EnableSSL?
我可以在程式碼中設置此屬性,但這不適用於簡單郵件 Web 事件和其他使用預設 Smtp 伺服器的類。有任何想法嗎?
對於 .NET 3 及更早版本:您不能。您必須手動管理它。
對於 .NET 4:可以。
請參閱<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>