smtp-after-pop发邮件

本文介绍了解决SMTP邮件发送问题的一种方法,即通过先进行POP验证再使用SMTP发送邮件的方式。这种方法适用于某些特定的邮件服务器配置。

    前两天客户说网站的发送邮件出了问题,代码是很正常的用smtp发邮件的代码,却总是不能通过验证,很诧异。后来联系客户才知道,原来客户的邮件服务器采用了smtp-after-pop的验证方式,即要先通过pop验证,才能通过smtp发送邮件,所以要在smtp发送代码前先加一部分pop验证的代码:

None.gif               string CRLF = "\r\n";
None.gif                TcpClient popServer 
= new TcpClient(smtpServer, 110);
None.gif
None.gif                NetworkStream netStrm 
= popServer.GetStream();
None.gif                StreamReader rdStrm 
= new StreamReader(popServer.GetStream());
None.gif                rdStrm.ReadLine();
None.gif
None.gif                
// Login Process
None.gif
                string data = "USER " + sender + CRLF;
None.gif                
byte[] szData = System.Text.Encoding.ASCII.GetBytes(data.ToCharArray());
None.gif                netStrm.Write(szData, 
0, szData.Length);
None.gif                rdStrm.ReadLine();
None.gif
None.gif                data 
= "PASS " + smtpPwd + CRLF;
None.gif                szData 
= System.Text.Encoding.ASCII.GetBytes(data.ToCharArray());
None.gif                netStrm.Write(szData, 
0, szData.Length);
None.gif                rdStrm.ReadLine();
None.gif

    这个通讯格式是RFC 1725的pop通讯格式
Client   : +OK Server POP  Ready!!
Client   : USER xxx
Server   : +OK
Client   : PASS yyy
Server   : +OK user successfully logged on
Client   : STAT
Server   : +OK n m
Client   : RETR 1
Server   : +OK
---{ data }-----
Client   : QUIT
Server   : +OK Server POP signing off

转载于:https://www.cnblogs.com/zhaoyan99/archive/2006/12/27/605206.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值