asp.net – 如何在Web.config中启用SmtpClient的SSL

有没有办法从web.config设置EnableSSL?

我可以在代码中设置此属性,但是对于Simple Mail Web事件和使用认Smtp服务器的其他类来说,这不是有效的。有任何想法吗?

解决方法

对于.NET 3及更早版本:您不能。你必须手工管理。

有关更多信息,请参见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/

对于.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>

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...