2013-10-01 96 views
18

下面的代码在本地工作正常,但如果上传它上godaddy它不工作。SMTP服务器需要安全连接或客户端未通过身份验证。如果上传上godaddy

错误:显示

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

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

PLZ检查下面的代码

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"; 

回答

34

您应该启用应用程序来访问Gmail帐户。 This link will help you

+4

这是什么样的链接?它有什么作用?我是否需要在所有要使用我的帐户的计算机上运行它? – Robert

+1

看看http://stackoverflow.com/questions/34851484/how-to-send-an-email-in-net-according-to-new-google-security-policies – 2016-01-20 08:28:25

16

我有同样的问题。

我发现这个解决方案:

谷歌可能会在一些应用或设备不使用最新安全标准的企图阻止迹象。由于这些应用和设备更容易侵入,因此阻止这些应用和设备有助于保持帐户安全。

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

在您的iPhone或iPad上的邮件应用程序与iOS 6以下 的邮件应用程式Windows手机的8.1版本 一些桌面前上像Microsoft Outlook和Mozilla Thunderbird这样的邮件客户端 因此,您必须在您的谷歌帐户中启用不太安全的登录。

标志到谷歌帐户后,请访问:

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

+0

哇,谢谢你。没有其他答案为我解决了这个问题。我觉得这是Google最近的变化,现在应该将此答案更新并接受为“答案”。 – AlexVPerl

+0

谢谢艾丁....救了我很多时间。 –

0

我也有这个问题从我的本地应用程序发送电子邮件,并尝试了许多不同的意见。

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

1

我刚刚遇到同样的问题。

试图Aidin伊斯拉米的答案,它只是做了部分工作:

在这里启用不够安全的应用访问后: https://www.google.com/settings/security/lesssecureapps 我设法从我的本地机器发送电子邮件,但不能从我的虚拟主机。

然后我发现这个谷歌支持页面: 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/DisplayUnlockCaptcha on 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.

按下按钮,在DisplayUnlockCaptcha一切正常后!

希望这可以帮助其他人。祝你好运。

相关问题