[ZT]System.Net.Mail with SSL to authenticate against port 465

System.Net.Mail 有时候在SSL SMTP Server下发送不成功, 找了一会儿, 貌似应该是这个问题了

Sending mail using System.Net.Mail with SSL will fail:

 

System.Net.NetworkCredential aCred = new System.Net.NetworkCredential("myacct", "mypassword");

SmtpClient smtp = new SmtpClient("smtp.mail.myserver.com", 465);

smtp.EnableSsl = true;

smtp.UseDefaultCredentials = false;

smtp.Credentials = aCred;

 

System.Net.Mail only supports “Explicit SSL”. 

 

Explicit SSL

System.Net.Mail only supports “Explicit SSL”.  Explicit SSL starts as unencrypted on port 25, then issues a STARTDLS and switches to an Encrypted connection.  See RFC 2228.

 

Explicit  SLL would go something like: Connect on 25 -> StartTLS (starts to encrypt) -> authenticate -> send data

 

If the SMTP server expects SSL/TLS connection right from the start then this will not work.

 

Implicit SSL

There is no way to use Implicit SSL (SMTPS) with System.Net.Mail.  Implicit SSL would have the entire connection is wrapped in an SSL layer.  A specific port would be used (port 465 is common).  There is no formal RFC covering Implicit SSL.

 

Implicit  SLL would go something like: Start SSL (start encryption) -> Connect -> Authenticate -> send data

 

This is not considered a bug, it’s a feature request. There are two types of SSL authentication for SMTP, and we only support one (by design) – Explicit SSL. 

原文地址: http://blogs.msdn.com/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx

转载于:https://www.cnblogs.com/forward/archive/2009/05/13/1455567.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值