[英]Cannot send email in C# on Server 2008, but works on Windows 7
I have code that uses System.Net.Mail.MailMessage to send an email on port 587 via smtp.gmail.com. 我有使用System.Net.Mail.MailMessage通过smtp.gmail.com在端口587上发送电子邮件的代码。 When I run this code via IIS on my computer with Windows 7, it works. 当我在装有Windows 7的计算机上通过IIS运行此代码时,它可以工作。 The email gets sent, and it arrives. 电子邮件已发送,然后到达。
The same exact code running on IIS on Windows Server 2008 does not work. Windows Server 2008上的IIS上运行的完全相同的代码不起作用。 All things held constant, the only difference is the operating system. 万物保持不变,唯一的区别是操作系统。 It's all running on the same network, so it's not a router security issue. 它们都在同一网络上运行,因此这不是路由器安全问题。 I've attempted to disable the outgoing firewall on port 587, but that did not work. 我试图禁用端口587上的传出防火墙,但这没有用。 I have attempted to apply the answers in the following two questions, but those didn't work either: 我试图在以下两个问题中应用答案,但这些方法也不起作用:
Sending email through a Google Apps account is working locally, but not on my web server 通过Google Apps帐户发送电子邮件在本地有效,但在我的网络服务器上不起作用
c# SmtpClient class not able to send email using gmail c#SmtpClient类无法使用gmail发送电子邮件
Anybody have any idea what security setting on Windows Server is preventing me from sending emails? 有人知道Windows Server上的哪些安全设置阻止我发送电子邮件吗?
The error I get: The remote name could not be resolved: 'smtp.gmail.com' 我收到的错误:无法解析远程名称:'smtp.gmail.com'
i faced this problem yesterday and i found the solution right now ,it is too late but hope this help some one else see this link ,the lines that you need is 我昨天遇到了这个问题,现在我找到了解决方案,为时已晚,但希望这可以帮助其他人看到此链接 ,您需要的行是
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};
and 和
Credentials = new NetworkCredential("xxx@zzz.ccc", "sdfsdf")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.