亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在C#中對SMTP進行身份驗證

如何在C#中對SMTP進行身份驗證

C#
江戶川亂折騰 2019-11-27 13:16:05
我創建使用SMTP發送消息的新ASP.NET Web應用程序。問題是smtp未被發送郵件的人驗證。如何在程序中對SMTP進行身份驗證?C#是否具有一個具有用于輸入用戶名和密碼的屬性的類?
查看完整描述

3 回答

?
莫回無

TA貢獻1865條經驗 獲得超7個贊

確保SmtpClient.Credentials 在致電后設置SmtpClient.UseDefaultCredentials = false。


該順序很重要,因為設置SmtpClient.UseDefaultCredentials = false將重置SmtpClient.Credentials為空。


查看完整回答
反對 回復 2019-11-27
?
交互式愛情

TA貢獻1712條經驗 獲得超3個贊

要通過TLS / SSL發送消息,您需要將SmtpClient類的Ssl設置為true。


string to = "[email protected]";

string from = "[email protected]";

MailMessage message = new MailMessage(from, to);

message.Subject = "Using the new SMTP client.";

message.Body = @"Using this new feature, you can send an e-mail message from an application very easily.";

SmtpClient client = new SmtpClient(server);

// Credentials are necessary if the server requires the client 

// to authenticate before it will send e-mail on the client's behalf.

client.UseDefaultCredentials = true;

client.EnableSsl = true;

client.Send(message);


查看完整回答
反對 回復 2019-11-27
  • 3 回答
  • 0 關注
  • 759 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號