使用 Google Apps 电子邮件/smtp 从网站发送邮件时出现问题

发布于 2024-11-14 08:43:26 字数 1193 浏览 4 评论 0原文

我有一个 Asp.Net 网站,它使用 google SMTP 发送电子邮件。使用以下配置,它可以与正常的 gmail 帐户一起正常工作。

<smtp from="[email protected]">
<network host="smtp.gmail.com" port="587" userName="[email protected]" password="mypassword" enableSsl="true" /></smtp>

现在我需要使用 Google Apps 电子邮件和 smtp,我尝试更改配置,如下所示,

<smtp from="[email protected]">
    <network host="smtp.gmail.com" port="587" userName="[email protected]" password="mypassword" enableSsl="true" /> </smtp>

但它抛出身份验证失败错误!!!
“SMTP 服务器需要安全连接,或者客户端未经过身份验证。服务器响应是:5.5.1 需要身份验证。了解更多信息”

我仔细检查了 Google 电子邮件设置、用户名和密码,但仍然无法解决问题!

关于这个问题的任何想法都会有很大的帮助。

谢谢和问候,
安兹

I have an Asp.Net site which uses google SMTP to send emails.. its working fine with normal gmail accounts using the below configuration

<smtp from="[email protected]">
<network host="smtp.gmail.com" port="587" userName="[email protected]" password="mypassword" enableSsl="true" /></smtp>

Now I need to use Google Apps email and smtp and I tried to change the configuration as shown below

<smtp from="[email protected]">
    <network host="smtp.gmail.com" port="587" userName="[email protected]" password="mypassword" enableSsl="true" /> </smtp>

But its throwing the Authentication failed error!!!
"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"

I double checked the Google EMail Settings, Username and password but still couldn't solve it!!

Any thoughts on the issue will be a great help..

Thanks and Regards,
Anz

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温柔戏命师 2024-11-21 08:43:26

来自 MSDN:

某些 SMTP 服务器要求
客户端在之前进行身份验证
服务器代表它发送电子邮件。放
当此属性为 true 时
SmtpClient 对象应该进行身份验证
使用默认凭据
当前登录的用户。如果
UseDefaultCredentials 属性已设置
为 false,则在中设置的值
凭证属性将用于
连接到时的凭据
服务器。


    client.UseDefaultCredentials = false;
    smtp.EnableSsl = true;
    client.Credentials = new System.Net.NetworkCredential(username, password);
    ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; 

    smtp.Send(mail);

另请查看此链接

From MSDN :

Some SMTP servers require that the
client be authenticated before the
server sends e-mail on its behalf. Set
this property to true when this
SmtpClient object should authenticate
using the default credentials of the
currently logged on user. If the
UseDefaultCredentials property is set
to false, then the value set in the
Credentials property will be used for
the credentials when connecting to the
server.


    client.UseDefaultCredentials = false;
    smtp.EnableSsl = true;
    client.Credentials = new System.Net.NetworkCredential(username, password);
    ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; 

    smtp.Send(mail);

Look to this link also.

迷爱 2024-11-21 08:43:26

您应该按照服务器响应(如果有)中的说明进行操作。也许,您需要比通常的用户名/密码模式更多/另一种身份验证方案。也许您可以在 google API 文档中找到更多答案?

You should follow the instructions in the server response (if any). Probably, you need more/another authentication scheme than the usual username/password pattern. Maybe you find more answers in the google API documentation?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文