Sending certified mail (System.Web.Mail.MailMessage) on port 465 (tls1.2) only fails on windows server 2008 r2
I have a function based on the framework 4.5 but that uses an old library (System.Web.Mail.MailMessage) to send an email through a smtp server on port 465 (certified mail tls1.2), the function runs correctly on windows 10 and windows server 2012 but it fails on windows server 2008 r2. the error is of type System.Web.HttpException indicating that it can not reach the server but doing the telnet on port 465 works. What's wrong with windows server 2008 r2?
try
{
System.Web.Mail.MailMessage newMail = new System.Web.Mail.MailMessage();
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "server");
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username");
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "pwd");
newMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
newMail.From = "mail";
newMail.To = "mail";
newMail.Subject = "test web Mail";
newMail.BodyFormat = System.Web.Mail.MailFormat.Html;
newMail.Body = "body....";
newMail.Priority = System.Web.Mail.MailPriority.High;
System.Web.Mail.SmtpMail.SmtpServer = "smtpserver:465";
System.Web.Mail.SmtpMail.Send(newMail);
Console.WriteLine("Email Send");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
System.We.HttpException (0x80004005) the transport failed to connect to the server