我想用ASP.NET中的SMTPClient使用GoDaddy郵件服務器發送郵件,我的代碼如下,我嘗試了GoDaddy中的所有端口,但是我無法發送郵件無法從ASP.NET中的godaddy郵件服務器發送郵件
我的代碼:
try
{
//Mail Message
MailMessage mM = new MailMessage();
//Mail Address
mM.From = new MailAddress("[email protected]");
//receiver email id
mM.To.Add("[email protected]");
//subject of the email
mM.Subject = "your subject line will go here";
mM.Body = "Body of the email";
mM.IsBodyHtml = true;
//SMTP client
SmtpClient sC = new SmtpClient();
//credentials to login in to hotmail account
sC.Credentials = new NetworkCredential(username, password);
//port number for Hot mail
sC.Port = 25;
sC.Host = "smtpout.asia.secureserver.net";
sC.UseDefaultCredentials = false;
//enabled SSL
sC.EnableSsl = false;
sC.DeliveryMethod = SmtpDeliveryMethod.Network;
sC.Timeout = 40000;
//Send an email
sC.Send(mM);
}
catch (Exception ex)
{
var temp = ex.Message;
}
我也使用端口號465與enablessl =真實的,但沒有成功
什麼「不起作用」呢?你有沒有例外? –
是的,我得到一個異常,如「** SMTP服務器需要安全連接或客戶端未經過身份驗證。服務器響應是:需要身份驗證**」這是爲端口號25 而當我使用端口號465與EnableSsl = true,我得到一個異常「** {」無法從傳輸連接讀取數據:net_io_connectionclosed。「} **」 – Bharath
嘗試端口587和enablessl = true – jsanalytics