Cannot send mail to C # using outgoing servers such as Gmail / Yahoo using port 465

Using the System.Net.Mail namespace, the following code is used.

MailMessage MyMailMessage = new MailMessage("example@gmail.com", "example@gmail.com",

"write your subject Here ", "Hi,This is the test message ");

MyMailMessage.IsBodyHtml = false;

NetworkCredential mailAuthentication = new NetworkCredential("example@gmail.com","xxxxxxxx");

    SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 465);

    mailClient.EnableSsl = true;

    mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;

    mailClient.UseDefaultCredentials = false;

    mailClient.Credentials = mailAuthentication;

    mailClient.Send(MyMailMessage);

Using the above code timeout exception occurs if port 465 is used. Port 25 works fine. In the case of a yahoo account, both 465 and 25 refuse to send mail.

Is it possible to support a 465-port port for sending letters using a gmail or yahoo account.

Link to the following link http://blogs.msdn.com/b/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx

Indicates that Windows Mail uses System.Net.Mail to send messages - it does not work with implicit SSL.

Is there any solution to solve this problem.

Thanks in advance

+5
1

, .NET SSL. SMTP, , SSL.

+2

All Articles