【问题标题】:Cannot send email in C# on Server 2008, but works on Windows 7无法在 Server 2008 上使用 C# 发送电子邮件,但可以在 Windows 7 上使用
【发布时间】:2012-06-02 08:41:05
【问题描述】:

我的代码使用 System.Net.Mail.MailMessage 通过 smtp.gmail.com 在端口 587 上发送电子邮件。当我在装有 Windows 7 的计算机上通过 IIS 运行此代码时,它可以工作。电子邮件已发送,并且到达。

在 Windows Server 2008 上的 IIS 上运行的完全相同的代码不起作用。一切都保持不变,唯一的区别是操作系统。它们都在同一个网络上运行,所以这不是路由器安全问题。我试图禁用端口 587 上的传出防火墙,但没有奏效。我已尝试在以下两个问题中应用答案,但也没有奏效:

Sending email through a Google Apps account is working locally, but not on my web server

c# SmtpClient class not able to send email using gmail

有人知道 Windows Server 上的什么安全设置阻止我发送电子邮件吗?

我得到的错误: 无法解析远程名称:'smtp.gmail.com'

【问题讨论】:

  • 主机名可以解析吗?打开命令提示符并输入 nslookup smtp.gmail.com
  • 只是一个健全性检查:ping smtp.gmail.com 是否产生结果?
  • nslookup smtp.gmail.com 不起作用。响应是“UnKnown can't find smtp.gmail.com: No response from server”
  • ping smtp.gmail.com 也没有反应
  • DNS 问题?你连接到互联网了吗?

标签: .net email iis smtp windows-server-2008


【解决方案1】:

我昨天遇到了这个问题,我现在找到了解决方案,为时已晚,但希望这对其他人有帮助 看到这个link,你需要的行是

 ServicePointManager.ServerCertificateValidationCallback =
                delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
                {
                    return true;
                };

 Credentials = new NetworkCredential("xxx@zzz.ccc", "sdfsdf")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-17
    • 1970-01-01
    相关资源
    最近更新 更多