c# - Getting Exception Sending Email through Smtp Client in Xamarin -


i getting error when sending email through c# code in android app

534-5.7.14 please log in via web browser , 534-5.7.14 try again. 534-5.7.14 learn more @ 534 5.7.14 https://support.google.com/mail/answer/78754 n10sm18967460pap.16 - gsmtp

mailmessage message = new mailmessage();             message.from = new mailaddress("xxx@gmail.com");             message.to.add(new mailaddress("xxx@gmail.com"));             message.subject = "hai";             message.body = "test mail";              smtpclient client = new smtpclient("smtp.gmail.com", 587);             client.enablessl = true;              client.credentials = new system.net.networkcredential("xx@gmail.com", "password");             servicepointmanager.servercertificatevalidationcallback = delegate(object sende,x509certificate certificate, x509chain chain, system.net.security.sslpolicyerrors sslpolocy) {                 return true;             };              //client.deliverymethod = smtpdeliverymethod.network;              client.send(message);             toast.maketext(this, "sending mail...", toastlength.long).show(); 

i sending email in xamarin getting above exception . canyou please me how can resolve.

here solution found online , did work me :

  1. open standard non-incognito google window (i reference window 1) , logout google account.
  2. open incognito google window (i reference [2]) , logout google account.
  3. in window 1, login personal email xx@gmail.com
  4. in window 1, open account security settings navigating account -> sign-in & security , scroll down "allow less secure apps" setting. if setting turned on, turn off, wait 5 seconds, , turn on again (this quite crucial far understand). if setting turned off, turn on.
  5. in window 1, open https://accounts.google.com/displayunlockcaptcha link , click button unlock captcha. 5.1. not in 1
  6. in window 2, login company email or other email
  7. in window 2, open https://accounts.google.com/displayunlockcaptcha link , click button unlock captcha
  8. in window 2, in mail.google.com tab, open settings -> accounts, click add email address own
  9. in opened modal window, enter whatever name , personal email address - xx@gmail.com , click next step
  10. smtp server should set smtp.gmail.com, port 587, username xx@gmail.com (not john.doe), type in password personal xx@gmail.com address (please note don't have 2 step verification enabled, if have - please note may need enter different password)
  11. click connect , won't receive noisy "server response: 534-5.7.14" error

this approach encountered quite accidentally, google authors should write more specific or google developers should try reproduce , fix issue.

link original article here


Comments