开发者

Problem with Google Apps email/smtp to send mails from website

开发者 https://www.devze.com 2023-03-11 23:31 出处:网络
I have an Asp.Net site which uses google SMTP to send emails.. its working fine with normal gmail accounts using the below configuration

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" 开发者_Go百科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

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

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


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.


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号