c# - SMTP Server Authentication Error -


i'm working on app send crash report email if global threading exception invoked. however, every time try send email, error

the smtp server requires secure connection or client not authenticated. server response was: 5.5.1 authentication required. learn more at. <-- error message ends here seems weird.

my exception event handler looks this:

private void currentdomain_unhandledexception(object sender, unhandledexceptioneventargs e)     {         mailaddress fromaddress = new mailaddress("user@domain.com", "mary");         mailaddress toaddress = new mailaddress("user@domain.com", "sam");         const string frompassword = "password";         const string subject = "exception report";         exception exception = e.exceptionobject exception;         string body = exception.message + "\n" + exception.data + "\n" + exception.stacktrace + "\n" + exception.source;          var smtp = new smtpclient         {             host = "smtp.gmail.com",             port = 587,             enablessl = true,             deliverymethod = smtpdeliverymethod.network,             usedefaultcredentials = false,             credentials = new networkcredential(fromaddress.address, frompassword)         };         using (mailmessage message = new mailmessage(fromaddress, toaddress)         {             subject = subject,             body = body         })         {             try             {                  smtp.send(message);             }            catch(exception err)             {                 console.writeline("could not send e-mail. exception caught: " + err);             }         }     } 

does know why getting server authentication error?

google may block sign in attempts apps or devices not use modern security standards. since these apps , devices easier break into, blocking them helps keep account safer.

some examples of apps not support latest security standards include:

  • the mail app on iphone or ipad ios 6 or below
  • the mail app on windows phone preceding 8.1 release
  • some desktop mail clients microsoft outlook , mozilla thunderbird

therefore, have enable less secure sign-in in google account.

after sign google account, go to:

https://www.google.com/settings/security/lesssecureapps


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -