服务器拒绝了发件人地址。服务器响应为: 503 Error: need EHLO and AUTH first !

d2600 2008-07-07 04:33:55
昨天注册的163的邮箱,然后用.net测试发邮件不成功!!下面是发送代码:
private void SendMail(string from,string to,string username,string pwd,string subject,string body)
{
System.Web.Mail.MailMessage mailObj = new System.Web.Mail.MailMessage();

// 设置邮件的发送及接收地址
mailObj.From = from;
mailObj.To = to;

mailObj.Subject = subject;
mailObj.Body = body;

// html格式的邮件
mailObj.BodyFormat = MailFormat.Html;


// 设置为高级优先权
mailObj.Priority = MailPriority.High;

mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//进行验证
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", username); //用户名
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pwd); //密码
// 使用SmtpMail对象发送邮件
SmtpMail.SmtpServer="smtp.163.com";
SmtpMail.Send(mailObj);


}
...全文
5191 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovefeng5201314 2009-10-15
  • 打赏
  • 举报
回复
可以发的!
问题出错在这里
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//进行验证
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", username); //用户名
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pwd); //密码
suren77528 2009-05-11
  • 打赏
  • 举报
回复
这个我知道的,你用sina的服务器测试。
SmtpMail.SmtpServer="smtp.sina.com";
别的现在不支持
163 qq的都不行。
我今天用了sina的测试了,测试成功。
muziisboy 2009-04-23
  • 打赏
  • 举报
回复
我用的是jsp测试也是有同样的错误,
d2600 2008-07-07
  • 打赏
  • 举报
回复
服务器拒绝了发件人地址。服务器响应为: 503 Error: need EHLO and AUTH first !
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Runtime.InteropServices.COMException: 服务器拒绝了发件人地址。服务器响应为: 503 Error: need EHLO and AUTH first !

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:


[COMException (0x8004020e): 服务器拒绝了发件人地址。服务器响应为: 503 Error: need EHLO and AUTH first !
]

[TargetInvocationException: 调用的目标发生了异常。]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +468
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +58

[HttpException (0x80004005): 未能访问“CDO.Message”对象。]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +113
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1550
System.Web.Mail.SmtpMail.Send(MailMessage message) +150
B2Bsite.User_Register.SendMail(String from, String to, String username, String pwd, String subject, String body) in c:\inetpub\wwwroot\user_register.aspx.cs:253
B2Bsite.User_Register.Button2_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\user_register.aspx.cs:220
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292


62,133

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧