SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应是:5.5.1 需要身份验证?
SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required?
我在 windows 应用程序和 C# 中工作,我正在使用以下代码发送电子邮件。该代码在我的系统中无法正常工作:
MailMessage mailmsg = new MailMessage();
SmtpClient smtpclient = new SmtpClient();
mailmsg.To.Add(txtTo.Text);
mailmsg.CC.Add(txtCC.Text);
mailmsg.Subject = txtSubj.Text;
mailmsg.From = new MailAddress("buvana@gmail.com");
mailmsg.Body = txtbody.Text;
smtpclient.Port = 587;
smtpclient.Host = "smtp.gmail.com";
smtpclient.EnableSsl = true;
smtpclient.UseDefaultCredentials = false;
smtpclient.Credentials = new NetworkCredential("buvana@gmail.com", "*********");
smtpclient.Send(mailmsg);
如何解决这个问题。
收到此错误:
SMTP server requires a secure connection or the client was not authenticated
The server response was: 5.5.1 Authentication Required
你的代码好像没问题,useDefaultCredentials
是假的,端口是587等等
我认为问题是您需要按照以下说明配置 Gmail 以允许安全性较低的应用程序:https://support.google.com/accounts/answer/6010255?hl=en
Go to the "Less secure apps" section in My Account.
Next to "Access for less secure apps," select Turn on. (Note to Google Apps users: This setting is hidden if your administrator has locked less secure app account access.)
如果您使用 2 因素身份验证,则需要为您的应用程序创建一个新的应用程序密码并使用该密码登录。
我在 windows 应用程序和 C# 中工作,我正在使用以下代码发送电子邮件。该代码在我的系统中无法正常工作:
MailMessage mailmsg = new MailMessage();
SmtpClient smtpclient = new SmtpClient();
mailmsg.To.Add(txtTo.Text);
mailmsg.CC.Add(txtCC.Text);
mailmsg.Subject = txtSubj.Text;
mailmsg.From = new MailAddress("buvana@gmail.com");
mailmsg.Body = txtbody.Text;
smtpclient.Port = 587;
smtpclient.Host = "smtp.gmail.com";
smtpclient.EnableSsl = true;
smtpclient.UseDefaultCredentials = false;
smtpclient.Credentials = new NetworkCredential("buvana@gmail.com", "*********");
smtpclient.Send(mailmsg);
如何解决这个问题。
收到此错误:
SMTP server requires a secure connection or the client was not authenticated
The server response was: 5.5.1 Authentication Required
你的代码好像没问题,useDefaultCredentials
是假的,端口是587等等
我认为问题是您需要按照以下说明配置 Gmail 以允许安全性较低的应用程序:https://support.google.com/accounts/answer/6010255?hl=en
Go to the "Less secure apps" section in My Account.
Next to "Access for less secure apps," select Turn on. (Note to Google Apps users: This setting is hidden if your administrator has locked less secure app account access.)
如果您使用 2 因素身份验证,则需要为您的应用程序创建一个新的应用程序密码并使用该密码登录。