System.Net.Mail.SmtpException:SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证 [英] System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required

查看:416
本文介绍了System.Net.Mail.SmtpException:SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string to = txteml.Text;
string from = "myemail@gmail.com";
string subject = "code";
string body = code;
using (MailMessage mm = new MailMessage("myemail@gmail.com", txteml.Text))
{
    mm.Subject = "FriendsCity";
    mm.Body = "hi";
    mm.IsBodyHtml = false;
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com";
    smtp.EnableSsl = true;
    NetworkCredential NetworkCred = new NetworkCredential("myemail@gmail.com", "*mypassword*");
    smtp.UseDefaultCredentials = true;
    smtp.Credentials = NetworkCred;
    smtp.Port = 587;
    smtp.Send(mm);
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true);
}

推荐答案

至少使用你的标题作为搜索短语进行快速搜索。



发送问题使用asp.net中的免费smtp服务器发送电子邮件 [ ^ ]
At least do a quick search using your title as the search phrase.

problems in sending email using free smtp server in asp.net[^]


问题(您正在谈论的问题)来自您未使用EnableSsl或何时您的网络凭据错误。



请阅读我的以下文章,通过.NET框架发送电子邮件,以及一般问题 - 使用C#代码 [ ^ ],因为它涵盖了这些主题以及使用时可能找到的更多主题a href =https://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient(v=vs.110).aspx> SmtpClient [ ^ ]。
The problem (the one you are talking about) comes when you are either not using EnableSsl or when your network credentials are wrong.

Please read this following article of mine, Sending emails over .NET framework, and general problems – using C# code[^], as it covers these topics and a few more that may be found while working with SmtpClient[^].


这篇关于System.Net.Mail.SmtpException:SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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