2

code:

import smtplib
content = 'My name is aniket'
mail = smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login('xxxxxx@gmail.com','xxxxxxxx')
mail.sendmail('xxxxxxxx@gmail.com','xxxxxxxx@gmail.com',content)
mail.close()

error:

Traceback (most recent call last):
  File "C:/Users/devda/Desktop/send.py", line 6, in <module>
    mail.login('xxxxxxx@gmail.com','xxxxxxxx')
  File "C:\Users\devda\AppData\Local\Programs\Python\Python36\lib\smtplib.py", line 730, in login
    raise last_exception
  File "C:\Users\devda\AppData\Local\Programs\Python\Python36\lib\smtplib.py", line 721, in login
    initial_response_ok=initial_response_ok)
  File "C:\Users\devda\AppData\Local\Programs\Python\Python36\lib\smtplib.py", line 642, in auth
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbsd\n5.7.14 oAW9mycTf-jZDqcjz5vsu0ogmAjpTX27Q2SyCnw_YU3rEHQ9knhX2CS4Dwbd7gvSHHYqPn\n5.7.14 LhLWk3yeRfc76JhNgJ3WF_OzpccCToenoxbBIyjx4CpFAoA1inmpeY0ioqA7wYxO6jT2gU\n5.7.14 Kq4LuAMjuCqzM6QeGbJVtkY318EeQ_6F-jEpt2Uld-dgUPq-tRqSnRgfAGS9pZSuWo1EUa\n5.7.14 amFh3RNscfumLIV9jzFzhUyLVWnoQ6ot7r1Vm3eCE9bA5vhlqHAaZEUgqRwkRPijJWSCQk\n5.7.14 sLa9aiP4xcHbk9RmxsI56uKeabHZtimxXDS-a62Ib9-QNZcYgaoA-3BQe_oC76sgWsJB_K\n5.7.14 Im-kfI9dQ-qcufBmiFd6W2fjmGViidjGkmhpC8gtoroEy2BQ5CO26FN5PgGtoFlLcsaRRK\n5.7.14 hU8Uj390kKWCsriq6LMwCwLEY_t0A7BhBNpTzdyuX5rviZYx3uz1UvAQvJa45QpwE0LV4w\n5.7.14 em_ao> Please log in via your web browser and then try again.\n5.7.14  Learn more at\n5.7.14  https://support.google.com/mail/answer/78754 p3-v6sm5068792pfg.175 - gsmtp')

I am trying to send a simple email using python. This code is taken from youtube tutorial. I checked the other questions on stack overflow but none of them have this kind of error. I dont know what kind of error is this or how i could resolve it. The login credentials are correct. The account doesnt have 2-step verification.

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
Aniket Bote
  • 3,456
  • 3
  • 15
  • 33
  • This has some good trouble shooting steps: https://stackabuse.com/how-to-send-emails-with-gmail-using-python/ Try this: `import smtplib try: server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() # ...send emails except: print ('Something went wrong...')` – sniperd Sep 25 '18 at 17:28
  • It will just catch the exception it wont solve the error right? – Aniket Bote Sep 25 '18 at 17:44
  • 3
    I am guessing that you have configured your Gmail to allow less secure apps to access your account or this link might help you. https://www.google.com/accounts/DisplayUnlockCaptcha. I would also recommend checking out this SOF answer https://stackoverflow.com/a/27515833/6867321 – Saransh Singh Sep 25 '18 at 18:21

0 Answers0