【发布时间】:2014-07-20 00:47:11
【问题描述】:
如何解决这个 SMTP 错误问题?当我发送邮件时,我正面临此错误消息。使用本地系统发送邮件不是问题。有谁知道这个问题的解决方案吗?
System.Net.Mail.SmtpException:SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应为:5.5.1 需要身份验证。
在 System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode,字符串响应)
在 System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] 命令, MailAddress from, Boolean allowUnicode)
在 System.Net.Mail.SmtpTransport.SendMail(MailAddress 发件人,MailAddressCollection 收件人,String deliveryNotify,布尔 allowUnicode,SmtpFailedRecipientException& 异常)
在 System.Net.Mail.SmtpClient.Send(MailMessage 消息)
在 c:\inetpub\vhosts\starlineroadways.com\httpdocs\admin_booking.aspx.cs:line 596 中的 admin_booking.btninvoicemail_Click(Object sender, EventArgs e) 代码:
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);
【问题讨论】:
-
请提供相关代码..
-
IIS 是否正确配置了邮件服务器详细信息?
-
欢迎来到 SO!显然,“需要身份验证”是错误所说的问题。请分享
admin_booking.aspx.cs后面的相关代码中的代码,以便人们可以看到您是否遗漏了某些内容(您是什么,身份验证)。