c# - Mail Error:The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required -


i using following code send email. code not working getting error message

try {     mailmessage message = new mailmessage(mfrom, "xyz@gmail.com",msubject,mmsg);     smtpclient mysmtpclient = new smtpclient("smtp.gmail.com",587);     mysmtpclient.credentials = icredentialsbyhost)credentialcache.defaultnetworkcredentials;     mysmtpclient.deliverymethod = smtpdeliverymethod.network;     mysmtpclient.usedefaultcredentials = true;     mysmtpclient.enablessl = true;     mysmtpclient.send(message); } catch (formatexception ex)             {                 messagebox.show(ex.stacktrace, ex.message, messageboxbuttons.ok, messageboxicon.error);             }             catch (smtpexception ex)             {                 messagebox.show(ex.stacktrace, ex.message, messageboxbuttons.ok, messageboxicon.error);             }             catch (exception ex)             {                 messagebox.show(ex.stacktrace, ex.message, messageboxbuttons.ok, messageboxicon.error);             } 

the following smtpexception exception been catched

the smtp server requires secure connection or client not authenticated. server response was: 5.5.1 authentication required.

thanks...


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -