import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login("******@gmail.com", "*******")
msg = "Hello!"
server.sendmail("rajesh.debugs@gmail.com", "rjucsm@gmail.com", msg)
ВЫХОД:
C:\Users\Admin\PycharmProjects\Gabbar\venv\Scripts\python.exe C:/Users/Admin/PycharmProjects/Gabbar/MadhuBhai/t3.py
Traceback (most recent call last):
File "C:/Users/Admin/PycharmProjects/Gabbar/MadhuBhai/t3.py", line 5, in <module>
server.login("******@gmail.com", "******")
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 730, in login
raise last_exception
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 721, in login
initial_response_ok=initial_response_ok)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\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=AKgnsbtX\n5.7.14 HDzghr7H0UegF2rvoxWT6p9FwK8ct-IgZQXTa09qiineo743EE4PjOLOukbW-7fN2_FfIx\n5.7.14 qBwOghPCGmq1zlaUP3231EHWXgeut6dhRtiEjEVKAd-VKglbnUqvCyPMLKlADKhWt56L_5\n5.7.14 afzoYLGapj8SmZxp_W6VMrkj10aK9xthTsrmUerV9bkqgILAnKh9SWOO2n-7WsHO43reIf\n5.7.14 MQqmW0G2lyXQWbYt-8LxUHRt3ATI8> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 v5-v6sm6337091pfd.1 - gsmtp')
Process finished with exit code 1