c# - the SMTP server requires a secure connection or the client was not authenticated. The server response was 5.5.1, Authentication required -


i have been trying application send email on hour now, , i've tried i've found online still exception mentioned in title of question.

here code used:

        smtpclient client = new smtpclient();         client.host = "smtp.gmail.com";         client.port = 587;         client.credentials = new networkcredential("sender email", "sender email password");         client.enablessl = true;         client.usedefaultcredentials = false;         client.deliverymethod = smtpdeliverymethod.network;          mailmessage mail = new mailmessage();         mail.from = new mailaddress("sender email", "sender");         mail.to.add(new mailaddress("my email"));         mail.subject = "test";         mail.isbodyhtml = true;         mail.body = sb.tostring();          client.send(mail); 

i have allowed access less secure apps on account. have tried enabling 2fa , generating application specific password, exception stays.

  1. check gmail account , turn on "acess less secure apps"

  2. set client.usedefaultcredentials = false; before client.credentials = new networkcredential("sender email", "sender email password");


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -