.Net邮件发送功能异常,求救!!!【100分】

Trouble___Maker 2012-02-22 01:02:28
本地发送一切正常,能够发送成功!
上传到服务器上后就出现了这种问题!(PS:服务器只是租的一个虚拟空间。)
异常信息如下:
(高手速来帮小弟看看!谢谢!)

System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.53.109:25

at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)

at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

--- End of inner exception stack trace ---

at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)

at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)

at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)

at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)

at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)

at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)

at System.Net.Mail.SmtpClient.GetConnection()

at System.Net.Mail.SmtpClient.Send(MailMessage message)

--- End of inner exception stack trace ---

at System.Net.Mail.SmtpClient.Send(MailMessage message)

at SendMail.ProcessRequest(HttpContext context)
...全文
769 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
Trouble___Maker 2012-02-22
  • 打赏
  • 举报
回复
[Quote=引用 20 楼 dongxinxi 的回复:]

应该是SMTP端口被那边给封了
[/Quote]
我也觉得要么是防火墙的问题,要么是端口的问题。
Trouble___Maker 2012-02-22
  • 打赏
  • 举报
回复
看来这帖子又要沉了
  • 打赏
  • 举报
回复
应该是SMTP端口被那边给封了
bzyqidaiwanmei 2012-02-22
  • 打赏
  • 举报
回复
帮忙顶一下,我得项目现在在服务器也有不少问题
释迦苦僧 2012-02-22
  • 打赏
  • 举报
回复
一般企业邮箱 貌似 在一定时间内 对同一个IP下发送的邮件数量有限制
163的貌似是60份在一小时内
EnForGrass 2012-02-22
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 wxr0323 的回复:]

果断联系服务商。
[/Quote]
果断支持子夜,服务器
yespie 2012-02-22
  • 打赏
  • 举报
回复
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server --->

ping下来远程服务器。看看连接是不是正常,然后用 telnet xxx.xxx.xxx.xxx 端口 看看这样能不能连接邮件服务器。
子夜__ 2012-02-22
  • 打赏
  • 举报
回复
果断联系服务商。
翘楚时代 2012-02-22
  • 打赏
  • 举报
回复
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.53.109:25


口译:系统.NET WEB异常:未能链接远程服务器——》.NET Sockets异常:尝试链接失败,原因是因为在特定时间内未能取得响应,或者设置的链接因为未能取得74.125.53.109:25的主机响应

我的理解是:你的虚拟空间FTP不能使用主机服务器的SMTP服务,不能与主机进行通信导致的。联系服务提供商吧!
Trouble___Maker 2012-02-22
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 xiaoyu821120 的回复:]

你telnet一下邮件服务器25端口,或者用outlook试着发送一下邮件
[/Quote]
服务器是租的虚拟空间,连远程桌面都没有,只有ftp。
xiaoyu821120 2012-02-22
  • 打赏
  • 举报
回复
你telnet一下邮件服务器25端口,或者用outlook试着发送一下邮件
Trouble___Maker 2012-02-22
  • 打赏
  • 举报
回复
关于这个功能,我已经测试过了,在本地可以发送成功,其他服务器上也可以发生成功,唯独在现在的服务器上不行。所以问题和程序本身的关系不大,估计应该是服务器的问题,但是具体是什么问题却不知道,所以请知道的高人提醒小弟下,再次感谢!
KimoGao 2012-02-22
  • 打赏
  • 举报
回复
建议看下我的一篇文章
http://blog.csdn.net/keymo_
其中的“学习笔记37”
夜色镇歌 2012-02-22
  • 打赏
  • 举报
回复
试试这个。。

/// <summary>
/// 用于发邮件的方法
/// </summary>
/// <param name="username">显示的发件人名称</param>
/// <param name="subject">显示的主题名称</param>
/// <param name="toname">收件人邮箱号码</param>
/// <param name="body">内容</param>
public static void SendMessage(string username, string subject, string toname, string body)
{
MailAddress from = new MailAddress("wen.2.0.0.8@163.com", username);
MailMessage mail = new MailMessage();
mail.Subject = subject;
mail.From = from;
//设置邮件的收件人
string address = "";
string displayName = "";

string[] mailNames = (toname + ";").Split(';');
foreach (string name in mailNames)
{
if (name != string.Empty)
{
if (name.IndexOf('<') > 0)
{
displayName = name.Substring(0, name.IndexOf('<'));
address = name.Substring(name.IndexOf('<') + 1).Replace('>', ' ');
}
else
{
displayName = string.Empty;
address = name.Substring(name.IndexOf('<') + 1).Replace('>', ' ');
}
mail.To.Add(new MailAddress(address, displayName));
}
}
//设置邮件的内容
mail.Body = body;
//设置邮件的格式
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
//设置邮件的发送级别
mail.Priority = MailPriority.Normal;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
SmtpClient client = new SmtpClient();
//设置用于 SMTP 事务的主机的名称,填IP地址也可以了
client.Host = "smtp.163.com";
//设置用于 SMTP 事务的端口,默认的是 25
//client.Port = 25;
client.UseDefaultCredentials = false;
//这里才是真正的邮箱登陆名和密码,比如我的邮箱地址是 hbgx@hotmail, 我的用户名为 hbgx ,我的密码是 xgbh
client.Credentials = new System.Net.NetworkCredential("邮箱帐号", "密码");
client.DeliveryMethod = SmtpDeliveryMethod.Network;
//都定义完了,正式发送了,很是简单吧!
client.Send(mail);
}
天下如山 2012-02-22
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 wbloveilove 的回复:]
引用 5 楼 vincent_void 的回复:

帮博哥顶贴啊!
人气,,人气呢?

操,别发这种没营养的文字好吧
[/Quote
蛋疼。
Trouble___Maker 2012-02-22
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 vincent_void 的回复:]

帮博哥顶贴啊!
人气,,人气呢?
[/Quote]
操,别发这种没营养的文字好吧
七色鸟 2012-02-22
  • 打赏
  • 举报
回复
http://blog.csdn.net/andrew_wx/article/details/6950555
这里面有一个,参考参考。
七色鸟 2012-02-22
  • 打赏
  • 举报
回复
帮博哥顶贴啊!
人气,,人气呢?
Trouble___Maker 2012-02-22
  • 打赏
  • 举报
回复
string strMailFrom = ConfigurationManager.AppSettings["mailFrom"];
string strMailFromPass = ConfigurationManager.AppSettings["MailFromPass"];
string strSmtpServer = ConfigurationManager.AppSettings["SmtpServer"];
SmtpClient client = new SmtpClient(strSmtpServer); //邮件发送类
client.UseDefaultCredentials = false;

client.Credentials = new NetworkCredential(strMailFrom, strMailFromPass);

client.EnableSsl = true;

client.DeliveryMethod = SmtpDeliveryMethod.Network;

string strSubject = string.Empty;
System.Text.StringBuilder strBody = new System.Text.StringBuilder();

strBody.Append("From:  " + context.Request["frm_name"] + "   <br />");
strBody.Append("EMail:  " + context.Request["frm_email"] + "   <br />");
//strBody.Append("Subject:  " + context.Request["frm_subject"] + "   <br />");
strSubject = context.Request["frm_subject"];
strBody.Append("Message:  " + context.Request["frm_message"] + "   <br />");

MailMessage message = null;


message = new MailMessage(strMailFrom, strMailTo, strSubject, strBody.ToString());

message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
try
{
client.Send(message);
}
catch (Exception ex)
{
context.Response.Write(ex.ToString());
}
Trouble___Maker 2012-02-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 insus 的回复:]

是不是服务器block了。
[/Quote]
能够得到的异常信息就这些
加载更多回复(2)

62,072

社区成员

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

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

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

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