gpt4 book ai didi

.net - 无法从 Azure 云服务使用 Gmail smtp

转载 作者:行者123 更新时间:2023-12-04 00:22:20 24 4
gpt4 key购买 nike

我通过 Gmail 的 smtp 发送电子邮件的代码:

SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("my_user_name", "my_password");

MailMessage message =
new MailMessage(new MailAddress("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1573677a783b3b3b557278747c793b767a78" rel="noreferrer noopener nofollow">[email protected]</a>"), new MailAddress("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfabb0f1f1f19fb8b2beb6b3f1bcb0b2" rel="noreferrer noopener nofollow">[email protected]</a>"));
message.Body = "body";
message.Subject = "subject";
client.Send(message);

当我在 Azure 上发布为“网站”时,该代码可以在我的本地计算机上运行。

但是当我在“云服务”中发布时,我收到此异常:

 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. Learn more at

Windows Azure“网站”与“云服务”之间有什么不同之处可以产生这种效果吗?

谢谢!

最佳答案

我遇到了这个确切的问题。然而,无论我使用<system.net>,我都遇到了这个问题。配置设置,我使用了正确的凭据、主机、端口等。

问题在于 Google 拒绝来自 Azure 的身份验证请求。我通过登录代码中用于 SMTP 客户端的 Gmail 帐户发现了这一点。登录 Gmail 帐户后,我注意到一个红色栏标题警告,上面写着

Someone signed in from a location that isn't typical for your account. If it wasn't you, change your password immediately.

除了警告之外,我还收到了一封电子邮件,内容如下:

Someone recently tried to use an application to sign in to your Google Account, [email protected]. 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:

  • Monday, August 27, 2012 10:33:59 PM GMT
  • IP Address: 168.62.48.183
  • Location: United States

If you do not recognize 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. Find out how at http://support.google.com/accounts?p=reset_pw

If this was you, and you want to give this application access to your account, complete the troubleshooting steps listed at http://support.google.com/mail?p=client_login

Sincerely, The Google Accounts Team

按照提供的链接中列出的步骤操作后,我的 Azure 网站能够成功登录我的 Gmail 帐户并使用 Gmail 作为 SMTP 客户端。

关于.net - 无法从 Azure 云服务使用 Gmail smtp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11018233/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com