C# SMTP 服务器需要安全连接或客户端未通过身份验证。如果上传到godaddy

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19111325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 14:07:31  来源:igfitidea点击:

The SMTP server requires a secure connection or the client was not authenticated. if uploading on godaddy

c#asp.netemailsmtp-auth

提问by Firoz Khan

below code is working fine in local, but if upload upload it on godaddy it is not working.

下面的代码在本地工作正常,但如果上传到godaddy,则无法正常工作。

Error: showing

错误:显示

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at

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

Line 53:        
Line 54:         smtp.EnableSsl = true;
Line 55:         smtp.Send(message);
Line 56: 
Line 57: 

plz check below code

请检查下面的代码

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

    message.To.Add(new MailAddress("[email protected]"));

    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("[email protected]", "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";

采纳答案by parhamparsa

you should enable application to access gmail account. This link will help you

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

回答by aidinism

I have the same problem.

我也有同样的问题。

I have found this solution:

我找到了这个解决方案:

Google may block sign in attempts from some apps or devices that do not use modern security standards. Since these apps and devices are easier to break into, blocking them helps keep your account safer.

Google 可能会阻止来自某些不使用现代安全标准的应用程序或设备的登录尝试。由于这些应用程序和设备更容易被入侵,因此阻止它们有助于确保您的帐户更安全。

Some examples of apps that do not support the latest security standards include:

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

The Mail app on your iPhone or iPad with iOS 6 or below The Mail app on your Windows phone preceding the 8.1 release Some Desktop mail clients like Microsoft Outlook and Mozilla Thunderbird Therefore, you have to enable Less Secure Sign-In in your google account.

装有 iOS 6 或更低版本的 iPhone 或 iPad 上的邮件应用程序 8.1 版本之前 Windows 手机上的邮件应用程序 一些桌面邮件客户端,如 Microsoft Outlook 和 Mozilla Thunderbird 因此,您必须在您的谷歌帐户中启用安全性较低的登录。

After sign into google account, go to:

登录谷歌账户后,前往:

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

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

回答by IronHide

I also had this issue with sending email from my local application and tried many different suggestions.

我在从本地应用程序发送电子邮件时也遇到了这个问题,并尝试了许多不同的建议。

After few hours of battling with this it turned out that the issue was related to the fact that I had 2 google accounts and I was using my second account and all setting were correct I even enabled lesssecureapps on this account but it still didn't work. Last thing I tried was to change the SmtpClient setup to use my other Gmail account and it all magically worked.

经过几个小时的斗争,结果证明这个问题与我有 2 个谷歌账户有关,我使用的是我的第二个账户,所有设置都是正确的,我什至在这个账户上启用了 lesssecureapps 但它仍然没有工作. 我尝试的最后一件事是更改 SmtpClient 设置以使用我的其他 Gmail 帐户,并且一切都神奇地起作用了。

回答by shahaf

I just encountered the same problem.

我刚刚遇到了同样的问题。

Tried Aidin Eslami's answer and it only did part job:

尝试了 Aidin Eslami 的回答,它只完成了部分工作:

After enabling less secure apps access in here: https://www.google.com/settings/security/lesssecureappsI managed to send emails from my local machine but not from my web host.

在此处启用不太安全的应用程序访问权限后:https: //www.google.com/settings/security/lesssecureapps我设法从我的本地机器发送电子邮件,但不是从我的网络主机发送。

And then I found this google support page: https://support.google.com/accounts/answer/6009563

然后我找到了这个谷歌支持页面:https: //support.google.com/accounts/answer/6009563

Still having trouble signing in?

If you've tried all the options above but are still unable to sign in to your account on the app, try the following:

Go to https://accounts.google.com/DisplayUnlockCaptchaon your device's browser. Enter your username and password, then type the letters on the screen. Go back to the app and try signing in again.

仍然无法登录?

如果您已尝试上述所有选项,但仍无法在应用程序上登录您的帐户,请尝试以下操作:

在您设备的浏览器上访问https://accounts.google.com/DisplayUnlockCaptcha。输入您的用户名和密码,然后输入屏幕上的字母。返回应用程序并尝试重新登录。

After pressing the button in the DisplayUnlockCaptcha everything works!

按下 DisplayUnlockCaptcha 中的按钮后,一切正常!

Hopes this helps others too. Good luck.

希望这对其他人也有帮助。祝你好运。