SMTP错误5.5.1,用户名,密码正确,ssl已启用。用gmail [英] SMTP Error 5.5.1, username, password correct, ssl enabled. with gmail

查看:214
本文介绍了SMTP错误5.5.1,用户名,密码正确,ssl已启用。用gmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MailMessage msg = new MailMessage();
SmtpClient client = new SmtpClient("smtp.gmail.com",587);
client.EnableSsl = true;        
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("myid@gmail.com","mypassword");
client.DeliveryMethod = SmtpDeliveryMethod.Network;    
msg.To.Add(new MailAddress("toid@yahoo.co.in"));
msg.From = new MailAddress("myid@gmail.com");
msg.Subject = "Test Mail";
msg.Body = "Body Of the E-mail";
try
{
    client.Send(msg);
    MessageBox.Show("Sent");
}
catch (Exception ex)
{
    MessageBox.Show("Error: " + ex);
    this.Dispose();
}





这是我的代码。谁能告诉我这有什么问题。我收到错误5.5.1需要进行身份验证。

更多错误详情 - SMTP服务器需要安全连接或客户端未经过身份验证。



i在测试时输入了正确的用户名和密码,但它不起作用。

plz不提供其他类似页面的链接,我已经花了6个小时查看它们。

提前感谢



this is my code. can someone tell me what is wrong with this. i am getting error 5.5.1 AUTHENTICATION REQUIRED.
Further Details of error-The SMTP server requires a secure connection or the client was not authenticated.

i entered the correct username and password while testing but it's not working.
plz don't give links to other similar pages, i have already spent 6 hrs looking at them.
thanks in advance

推荐答案

您的代码绝对正确。

我尝试使用两个不同的Gmail帐户代码。

使用第一个帐户发送邮件。通过使用第二个我可以重现你的例外。

这两个帐户的区别在于第一个使用普通认证,而第二个使用谷歌的双向认证。

我很确定最后一个场景适用于此处;)



请尝试添加新的应用程序专用密码(在您的Gmail帐户设置中)和在您的应用程序中使用此密码而不是常规帐户密码。
Your code is absolutely correct.
I tried your code with two different gmail accounts.
With the first account the message was sent. By using the second one I could reproduce your exception.
The difference with these two accounts is that the first one is using the plain authentication while the second one is using Google's two-way authentication.
I'm pretty sure the last scenario applies here ;)

Kindly try to add a new application specific password (in your gmail account settings) and use this one instead of your regular account password within your application.


Goto Account of Gmail , then select Connected apps & sites Allow less secure apps: ON(if this is off you cannot send mails through apps,or your websites )


这篇关于SMTP错误5.5.1,用户名,密码正确,ssl已启用。用gmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆