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

穿精又带淫゛_ 提交于 2019-12-07 13:41:14

问题


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>

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


回答1:


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.




回答2:


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?



来源:https://stackoverflow.com/questions/6262242/problem-with-google-apps-email-smtp-to-send-mails-from-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!