简体   繁体   English

无法在Server 2008上用C#发送电子邮件,但在Windows 7上可以使用

[英]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.

相关问题 使用TLS和SmtpAuth在.Net 4 / C#中发送带有System.Net.Mail.SmtpClient的电子邮件,可在本地使用,但不能在生产服务器上运行(win 2008 r2) - Sending email with System.Net.Mail.SmtpClient in .Net 4/C# with TLS and SmtpAuth, works locally but not on production server(win 2008 r2) 使用Windows Server 2008的Windows服务中的读取设置属性(C#) - Read Settings properties (C#) in a Windows service with Windows server 2008 如何使用C#在Windows Server 2008中写入事件日志? - How to write to eventlog in Windows Server 2008 using C#? 无法使用C#使用Office 365凭据发送电子邮件 - cannot send email using office 365 credentials using C# .NET Word Interop适用于Windows 7,但不适用于Server 2008 - .NET Word Interop works on Windows 7 but not on Server 2008 发送电子邮件列表c# - Send Email List c# 无法在 C# 中发送 email - unable to send email in C# C#如何发送邮件? - C# how to send email? 将PDF文档附加到电子邮件C#Windows应用程序-电子邮件不发送 - Attach PDF document to Email C# Windows Application - Email does not send out DoD CAC身份验证 - 使用.NET C#,Windows Server 2008 R2,IIS 7.5的客户端证书问题 - DoD CAC Authentication - Client Certificate Issue with .NET C#, Windows Server 2008 R2, IIS 7.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM