由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 219.142.78.189:58 ?????

dylanliu9301 2012-06-07 03:05:41
哪里出错了,求解

SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = false;
smtp.Host = "smtp.sina.cn";
smtp.Port =587;
smtp.UseDefaultCredentials = false;

smtp.Credentials = new NetworkCredential("dana156825961@sian.cn", "************");

MailMessage email = new MailMessage();

email.From = new MailAddress("dana156825961@sian.cn", "weijain", System.Text.Encoding.GetEncoding(936));
email.To.Add("156825961@qq.com");

email.Subject = "add new account";
email.Body = "you have a new account";
email.IsBodyHtml = false;
email.Priority = MailPriority.High;
smtp.Send(email);
lblMessage.Text = "User added successfully";
txtAddUser.Text = "";
由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 219.142.78.189:58
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Net.Sockets.SocketException: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 219.142.78.189:58

源错误:


行 112: email.IsBodyHtml = false;
行 113: email.Priority = MailPriority.High;
行 114: smtp.Send(email);
行 115: lblMessage.Text = "User added successfully";
行 116: txtAddUser.Text = "";


源文件: F:\SkySharp\SkySharp\SkySharp\SkySharp\ManageUsers.aspx.cs 行: 114

堆栈跟踪:


[SocketException (0x274c): 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 219.142.78.189:58]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224

[WebException: 无法连接到远程服务器]
System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +5501831
System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +202
System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +332
System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +160
System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +159
System.Net.Mail.SmtpClient.GetConnection() +35
System.Net.Mail.SmtpClient.Send(MailMessage message) +1213

[SmtpException: 发送邮件失败。]
System.Net.Mail.SmtpClient.Send(MailMessage message) +1531
SkySharp.ManagerDatabases.btnAddSubmit_Click(Object sender, EventArgs e) in F:\SkySharp\SkySharp\SkySharp\SkySharp\ManageUsers.aspx.cs:114
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


...全文
1952 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
极夜hyc 2014-06-07
  • 打赏
  • 举报
回复
请问问题是怎么解决的? 小弟遇到了相同的问题!
  • 打赏
  • 举报
回复
问题怎么解决的。。。
宝_爸 2012-06-07
  • 打赏
  • 举报
回复
访问不到smtp.sina.cn的587端口
dylanliu9301 2012-06-07
  • 打赏
  • 举报
回复
en,明白谢谢啦!
dylanliu9301 2012-06-07
  • 打赏
  • 举报
回复
由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 219.142.78.190:58
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Net.Sockets.SocketException: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 219.142.78.190:58

源错误:


行 112: email.IsBodyHtml = false;
行 113: email.Priority = MailPriority.High;
行 114: smtp.Send(email);
行 115: lblMessage.Text = "User added successfully";
行 116: txtAddUser.Text = "";


源文件: F:\SkySharp\SkySharp\SkySharp\SkySharp\ManageUsers.aspx.cs 行: 114

堆栈跟踪:


[SocketException (0x274c): 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 219.142.78.190:58]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224

[WebException: 无法连接到远程服务器]
System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +5501831
System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +202
System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +332
System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +160
System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +159
System.Net.Mail.SmtpClient.GetConnection() +35
System.Net.Mail.SmtpClient.Send(MailMessage message) +1213

[SmtpException: 发送邮件失败。]
System.Net.Mail.SmtpClient.Send(MailMessage message) +1531
SkySharp.ManagerDatabases.btnAddSubmit_Click(Object sender, EventArgs e) in F:\SkySharp\SkySharp\SkySharp\SkySharp\ManageUsers.aspx.cs:114
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565




--------------------------------------------------------------------------------
dylanliu9301 2012-06-07
  • 打赏
  • 举报
回复
注意到dana156825961.sian.cn颠倒了改回sina.cn提示无法发送邮件

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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