Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required(Gmail 错误:SMTP 服务器需要安全连接或客户端未通过身份验证.服务器响应是:5.5.1 Authentication Required) - IT屋-程序员软件开发技术分享社
问题描述
我正在使用以下代码发送电子邮件.该代码在我的本地机器上正常工作.但在生产服务器上我收到错误消息
I am using following code to send email. The Code works correctly in my local Machine. But on Production server i am getting the error message
var fromAddress = new MailAddress("mymailid@gmail.com");
var fromPassword = "xxxxxx";
var toAddress = new MailAddress("yourmailid@yourdoamain.com");
string subject = "subject";
string body = "body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
smtp.Send(message);
在我的 Gmail A/c 上,我从生产服务器运行代码后收到了以下电子邮件
And on my Gmail A/c I have received the following email after i ran the code from production server
你好,
最近有人使用您的密码尝试登录您的 Google帐户 mymailid@gmail.com.这个人正在使用这样的应用程序作为电子邮件、客户端或移动设备.
Someone recently used your password to try to sign in to your Google Account mymailid@gmail.com. This person was using an application such as an email, client or mobile device.
我们阻止了登录尝试,以防这是劫机者试图访问您的帐户.请查看登录尝试的详细信息:
We prevented the sign-in attempt in case this was a hijacker trying to access your account. Please review the details of the sign-in attempt:
2014 年 1 月 3 日星期五 13:56:08 点 UTC IP 地址:xxx.xx.xx.xxx(abcd.net.) 地点:Philadelphia PA, Philadelphia, PA, USA
Friday, 3 January 2014 13:56:08 o'clock UTC IP Address: xxx.xx.xx.xxx (abcd.net.) Location: Philadelphia PA, Philadelphia, PA, USA
如果您无法识别此登录尝试,则可能是其他人试图访问您的帐户.您应该登录您的帐户并立即重置您的密码.
If you do not recognise this sign-in attempt, someone else might be trying to access your account. You should sign in to your account and reset your password immediately.
重设密码
如果这是您,并且您无法访问自己的帐户,完成以下所列的故障排除步骤http://support.google.com/mail?p=client_login
If this was you and you are having trouble accessing your account, complete the troubleshooting steps listed at http://support.google.com/mail?p=client_login
此致,Google 帐户团队
Yours sincerely, The Google Accounts team
推荐答案
这通常发生在您尝试从不同时区或 IP 地址计算机登录时.您的生产服务器和您使用的邮件 ID 都在不同的时区.选择以下两种解决方案之一:
This generally happens when you try login from different time zone or IP Address Computer. Your production server and the mail id you have used both are in different time zone. Choose either of these two solutions:
1) 通过远程访问登录生产服务器,并使用您的凭据登录一次 gmail.他们会要求确认,确认并退出.
1) Log in to production server via remote access, and sign in to gmail once with your credentials. They will ask for the confirmation, confirm it and log out.
或 2) 将 gmail 登录到您的本地计算机,按照此 链接 并选择查看此活动并采取适当的措施.
Or 2) log in gmail to your local computer, Follow this Link and choose review this activity and take proper actions.
这篇关于Gmail 错误:SMTP 服务器需要安全连接或客户端未通过身份验证.服务器响应是:5.5.1 Authentication Required的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Gmail 错误:SMTP 服务器需要安全连接或客户端未通过身份验证.服务器响应是:5.5.1 Authentication Required
基础教程推荐
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- rabbitmq 的 REST API 2022-01-01