簡體   English   中英

無法使用端口465使用Gmail / Yahoo等外發郵件服務器在C#中發送郵件

[英]Unable to send mails in C# using Outgoing Mail Servers like Gmail/Yahoo using port 465

使用System.Net.Mail命名空間,使用的代碼如下所示。

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

如果使用465端口,則使用上述代碼超時異常。 25端口工作正常。 在雅虎帳戶的情況下,465和25都發送郵件失敗。

無論如何,使用gmail或yahoo帳戶發送郵件可以支持465端口。

參考以下鏈接http://blogs.msdn.com/b/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx

是否聲稱Windows Mail使用System.Net.Mail發送消息 - 不使用隱式SSL。

有沒有解決方案來解決這個問題。

提前致謝

這不是問題的答案,但.NET內置郵件類不支持所需的隱式SSL方法。您必須使用第三方SMTP客戶端組件才能同時使用顯式和隱式SSL。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM