简体   繁体   English

使用gmail发送电子邮件时出错。 SMTP服务器需要安全连接或客户端未通过身份验证

[英]Error on sending email using gmail. The SMTP server requires a secure connection or the client was not authenticated

Here is my code. 这是我的代码。

var smtp = new SmtpClient("smtp.gmail.com", 587)
        {

            EnableSsl = true,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            UseDefaultCredentials = false,
            Credentials = new NetworkCredential("sender@gmail.com","123")
        };
        try
        {
            smtp.Send("sender@gmail.com", "receiver@gmail.com", "test", "testbody");
        }
        catch (SmtpException e)
        {
            ltrInfo.Text=e.Message;
        }

When I debug the code, I get the error "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required" Please can you tell me what's the wrong with the code above? 调试代码时,出现错误“ SMTP服务器需要安全连接或客户端未通过身份验证。服务器响应为:5.5.1需要身份验证”请您告诉我上面的代码有什么问题吗?

Everything looks ok. 一切看起来还好。

Here are 2 possible solutions 这是2种可能的解决方案

Get to your Gmail account's security settings and set permissions for "Less secure apps" to Enabled. 转到您的Gmail帐户的安全设置,然后将"Less secure apps"权限设置为"Less secure apps"启用”。

Check if there is not a "Suspicious login attempt" on the top of the page, if is there click to authorizing the access 检查页面顶部是否没有"Suspicious login attempt" ,如果存在,请单击以授权访问

take a look on this Tell me if works. 看看这个,告诉我是否可行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 asp.net 发送电子邮件显示此错误:SMTP 服务器需要安全连接或客户端未通过身份验证 - Send email using asp.net shows this error:The SMTP server requires a secure connection or the client was not authenticated 如何修复 GMail SMTP 错误:“SMTP 服务器需要安全连接或客户端未通过身份验证。” - How to fix GMail SMTP error: "The SMTP server requires a secure connection or the client was not authenticated." Gmail 错误:SMTP 服务器需要安全连接或客户端未通过身份验证。 服务器响应是:5.5.1 Authentication Required - Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required SMTP服务器需要安全连接或客户端未经过身份验证 - The SMTP server requires a secure connection or the client was not authenticated SMTP 服务器需要安全连接或客户端未通过身份验证 - 错误 - The SMTP server requires a secure connection or the client was not authenticated - Error SMTP 服务器需要安全连接或客户端未通过身份验证。 使用 c# webapplication 发送 outlook 邮件时出错 - The SMTP server requires a secure connection or the client was not authenticated. Error while sending outlook mail using c# webapplication 使用Gmail发送邮件-例外“ SMTP服务器需要安全连接” - Sending mail using Gmail - exception “The SMTP server requires a secure connection” SMTP 服务器需要安全连接或客户端未通过身份验证。 服务器响应为:5.7.57 SMTP; Office 365 错误 - The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Office 365 error 出现错误:SMTP 服务器需要安全连接或客户端未通过身份验证。 服务器响应为:5.7.57 SMTP - Getting error : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP SMTP服务器需要安全连接,或者客户端未通过身份验证-连接超时 - The SMTP server requires a secure connection or the client was not authenticated— connection timed out
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM