谷歌应用程序的问题电子邮件/smtp从网站发送邮件

时间:2021-08-15 18:15:28

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

我有一个Asp。使用谷歌SMTP发送电子邮件的网站。使用下面的配置,可以正常使用gmail。

<smtp from="myname@gmail.com">
<network host="smtp.gmail.com" port="587" userName="myname@gmail.com" 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

现在我需要使用谷歌Apps email和smtp,并尝试更改如下所示的配置

<smtp from="myname@mydomain.com">
    <network host="smtp.gmail.com" port="587" userName="myname@mydomain.com" 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"

但是它抛出了认证失败的错误!!!SMTP服务器需要一个安全的连接,否则客户端没有经过验证。服务器响应为:5.5.1认证要求。学习更多在“

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

感谢和问候,澳新银行

2 个解决方案

#1


3  

From MSDN :

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

一些SMTP服务器要求在服务器代表其发送电子邮件之前对客户机进行身份验证。当这个SmtpClient对象使用当前登录的用户的默认凭据进行身份验证时,将该属性设置为true。如果将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);

Look to this link also.

也看看这个链接。

#2


0  

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?

您应该遵循服务器响应中的指令(如果有的话)。可能,您需要比通常的用户名/密码模式更多/另一个身份验证方案。也许您可以在谷歌API文档中找到更多的答案?

#1


3  

From MSDN :

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

一些SMTP服务器要求在服务器代表其发送电子邮件之前对客户机进行身份验证。当这个SmtpClient对象使用当前登录的用户的默认凭据进行身份验证时,将该属性设置为true。如果将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);

Look to this link also.

也看看这个链接。

#2


0  

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?

您应该遵循服务器响应中的指令(如果有的话)。可能,您需要比通常的用户名/密码模式更多/另一个身份验证方案。也许您可以在谷歌API文档中找到更多的答案?