0

I have code that uses System.Net.Mail.MailMessage to send an email on port 587 via smtp.gmail.com. When I run this code via IIS on my computer with Windows 7, it works. The email gets sent, and it arrives.

The same exact code running on IIS on Windows Server 2008 does not work. 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. 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

c# SmtpClient class not able to send email using gmail

Anybody have any idea what security setting on Windows Server is preventing me from sending emails?

The error I get: The remote name could not be resolved: 'smtp.gmail.com'

Community
  • 1
  • 1
carlbenson
  • 3,177
  • 5
  • 35
  • 54

1 Answers1

0

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")