SMTP服务器需要安全连接或客户端未经过身份验证.如果在godaddy上传

Fir*_*han 18 c# asp.net email smtp-auth

下面的代码在本地工作正常,但如果上传它上传到godaddy它不起作用.

错误:显示

SMTP服务器需要安全连接或客户端未经过身份验证.服务器响应为:5.5.1需要身份验证.了解更多信息

Line 53:        
Line 54:         smtp.EnableSsl = true;
Line 55:         smtp.Send(message);
Line 56: 
Line 57: 
Run Code Online (Sandbox Code Playgroud)

请检查以下代码

    MailMessage message = new MailMessage();
    message.From = new MailAddress(emailid.Text);

    message.To.Add(new MailAddress("receiver@gmail.com"));

    message.Subject = "NaatKhawan's Feedback";

    message.Body = "Selected: " + DropDownList1.Text.ToString() + "<br/><br/>Name: " + name.Text.ToString() + " <br/><br/>Email: " + emailid.Text.ToString() + " <br/><br/>Contact Number: " + phone.Text.ToString() + " <br/><br/>Message:<br/> " + remabox.Text.ToString();

    message.IsBodyHtml = true;

    // finaly send the email:
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com";

    smtp.Port = 587;
    smtp.Credentials = new System.Net.NetworkCredential("123@gmail.com", "123");

    smtp.EnableSsl = true;
    smtp.Send(message);
    lbltxt.Visible = true;
    name.Text = "";
    emailid.Text = "";
    phone.Text = "";
    remabox.Text = "";

    lbltxt.Text = "Thank you for supporting NaatKhawan";
Run Code Online (Sandbox Code Playgroud)

小智 36

您应该启用应用程序来访问Gmail帐户.此链接将帮助您

  • 那是什么联系?它有什么作用?我是否需要在我想使用帐户的所有计算机上运行它? (4认同)

小智 17

我也有同样的问题.

我找到了这个解决方案:

Google可能阻止某些不使用现代安全标准的应用或设备尝试登录.由于这些应用和设备更易于破解,因此阻止它们有助于确保您的帐户更安全.

一些不支持最新安全标准的应用程序示例包括:

iOS或更低版本的iPhone或iPad上的Mail应用程序8.1版本之前Windows手机上的Mail应用程序某些桌面邮件客户端(如Microsoft Outlook和Mozilla Thunderbird)因此,您必须在Google帐户中启用较少安全登录.

登录Google帐户后,请转到:

https://www.google.com/settings/security/lesssecureapps