Google Apps电子邮件/ smtp从网站发送邮件的问题 [英] Problem with Google Apps email/smtp to send mails from website

查看:573
本文介绍了Google Apps电子邮件/ smtp从网站发送邮件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Asp.Net网站,使用谷歌SMTP发送电子邮件..它的正常Gmail帐户使用以下配置工作正常

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="myname@gmail.com">
<network host="smtp.gmail.com" port="587" userName="myname@gmail.com" password="mypassword" enableSsl="true" /></smtp>

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

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

<smtp from="myname@mydomain.com">
    <network host="smtp.gmail.com" port="587" userName="myname@mydomain.com" password="mypassword" enableSsl="true" /> </smtp>

但是它抛出身份验证失败错误!!!

SMTP服务器需要安全连接或客户端未通过身份验证服务器响应是:5.5.1验证需要了解更多信息

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"

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

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..

感谢和问候,

Anz

Thanks and Regards,
Anz

推荐答案

从MSDN:


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

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);

查看此链接

这篇关于Google Apps电子邮件/ smtp从网站发送邮件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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