如何解决此SMTP错误问题?当我发送邮件时,我正面临此错误消息。使用本地系统发送邮件不是问题。有谁知道这个问题的解决方案?
System.Net.Mail.SmtpException:SMTP服务器需要安全连接,或者客户端未经过身份验证。服务器响应为:5.5.1需要验证 在System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode,String response)
在System.Net.Mail.MailCommand.Send(SmtpConnection conn,Byte []命令,MailAddress from,Boolean allowUnicode)
在System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,MailAddressCollection recipients,String deliveryNotify,Boolean allowUnicode,SmtpFailedRecipientException& exception)
在System.Net.Mail.SmtpClient.Send(MailMessage消息)
at admin_booking.btninvoicemail_Click(Object sender,EventArgs e)位于c:\ inetpub \ vhosts \ starlineroadways.com \ httpdocs \ admin_booking.aspx.cs:第596行 代码:
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential("xx@gmail.com", "xx");
System.Net.Mail.MailMessage oMsg = new System.Net.Mail.MailMessage();
MailAddress @add = new MailAddress(txtsendemail.Text);
oMsg.From = new MailAddress("xx");
oMsg.To.Add(@add);
oMsg.Subject = "xxx";
oMsg.Body = msgbody2;
oMsg.IsBodyHtml = true;
smtp.Send(oMsg);
答案 0 :(得分:0)
你可以试试这个。
MailMessage Mail = new MailMessage();
Mail.From = new MailAddress("xx@gmail.com");
Mail.To.Add(txtsendemail.Text);
Mail.Subject = "xxx";
Mail.Body = msgbody2;
SmtpClient smpt = new SmtpClient();
smpt.Credentials = new NetworkCredential("xx@gmail.com", "xx");
smpt.Port = 587;
smpt.Host = "smtp.gmail.com";
smpt.EnableSsl = true;
smpt.Send(Mail);