早上,我不明白爲什麼這段代碼不工作!謝謝,等待awnsers :)SMTP電子郵件不工作,5.7.1客戶端沒有權限發送作爲此發送人
protected void Enviar_Click(object sender, EventArgs e)
{
var pass = new NetworkCredential();
pass.UserName = "[email protected]";
pass.Password = "password";
var smtpClient = new SmtpClient();
smtpClient.Port = 587;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Credentials = pass;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
var email = new MailMessage(pass.UserName, "[email protected]", txtsubject.Text,
"name : " + txtname.Text + "menssage : " + txtMessage.Text);
SMTP.Enviar(email);
}
您花費大量時間設置SmtpClient,然後完全無法使用它。什麼是'SMTP'呢?我們是否想要猜測? – spender 2013-03-07 12:33:44
另請嘗試設置UseDefaultCredentials = false;在Credentials = Pass – 2013-03-07 12:34:56
之前沒有工作,我也改變了Web.config,但是它沒有改變,當它運行 – user2144202 2013-03-07 13:29:38