none
关于.net中如何使用STARTTLS加密传输邮件 RRS feed

  • 问题

  • SmtpClient 类中我只找到EnableSsl属性(这个包含STARTTLS嘛?),但我希望使用 STARTTLS,不知道如何使用,另外这个是否也要在邮件服务器上配置相关加密功能?有人对这个熟悉的嘛?谢谢
    2014年6月18日 6:02

答案

全部回复

  • Hi Fang lei,

    请注意看这个帖子:

    http://social.msdn.microsoft.com/Forums/en-US/db7713a8-926c-4ee7-adc7-933b525d2ed9/starttls-support?forum=netfxnetcom

    “Are you using the System.Net.Mail.SmtpClient object?  It sounds like you are implementing your own SMTP client on top of Sockets.  Our SmtpClient Object supports SSL and TLS already, so you shouldn't have to do anything with STARTTLS other than just set a boolean property to true.”

    “You should use EnableSSL=true. ”

     意思是SmtpClient已经默认支持SSL和TLS。

    MSDN文档中对于EnableSSL属性的解释 http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.enablessl(v=vs.110).aspx 也有如下:

    “The SmtpClient class only supports the SMTP Service Extension for Secure SMTP over Transport Layer Security as defined in RFC 3207. In this mode, the SMTP session begins on an unencrypted channel, then a STARTTLS command is issued by the client to the server to switch to secure communication using SSL. See RFC 3207 published by the Internet Engineering Task Force (IETF) for more information. ”

    根据这个博客 http://www.360doc.com/content/09/1231/02/495229_12346441.shtml TLS目的是使SSL更安全,并完善协议,可见他们的存在并不冲突。所以你要做的就是EnableSSL(just set a boolean property to true)。

    更具体详细的信息请去WCF论坛:http://social.microsoft.com/Forums/zh-CN/home?forum=wcfzhchs

    Regards,



    Barry Wang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • 已标记为答案 Fang Lei 2014年6月19日 4:48
    2014年6月19日 2:36
    版主
  • 非常感谢,能不能再问个问题,我把EnableSSL设为true后,我需要在邮件服务器上去配置以那种方式加密传输是嘛?也就是具体以何种方式加密取决于我自己的邮件服务器支持的加密方式可以这么理解嘛?另外打比方我自己的邮件服务器支持 TLS,但收件方不支持,就以明文方式发送?

    2014年6月19日 3:11
  • 这个问题还是WCF论坛的,你去WCF新开一个帖子来问吧。专门的问题到专门的论坛问比较合适。


    Barry Wang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年6月19日 3:15
    版主