How it works...

If you have not enabled less secure apps to access your email account, it may produce an error message similar to the following:

$ python 5_10_secure_mail_client.py 
Enter your Password:
Traceback (most recent call last):
  File "5_10_secure_mail_client.py", line 50, in <module>
    mail_client(given_args.host, given_args.port, given_args.fromAddress, password, given_args.toAddress, given_args.subject, given_args.body)
  File "5_10_secure_mail_client.py", line 31, in mail_client
    mailserver.login(fromAddress, password)
  File "/usr/lib/python3.5/smtplib.py", line 729, in login
    raise last_exception
  File "/usr/lib/python3.5/smtplib.py", line 720, in login
    initial_response_ok=initial_response_ok)
  File "/usr/lib/python3.5/smtplib.py", line 641, in auth
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, b'5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbv9
5.7.14 d-4CxD9A0qK3z36XteHYOlFaK2-idda9-3CG5ckc1xi_E1OgaK2aftyHvZvti9jX6fC1kd
5.7.14 fbTWvC5gKXK_A94zOBm8YQ_myr0uzInTP-Tf2pTdAZcz3owptTesXllHyXD2SCRHEXRJtk
5.7.14 nr-x8QQneko1ZBJCvsbtEmo5EXgETNbESSXmbX7acCZQGukSJJ-5akizNPUrxb6NVMsJwh
5.7.14 L-f5XsY1lBjmIlX9GVyQEZQSB-Iis> Please log in via your web browser and
5.7.14 then try again.
5.7.14  Learn more at
5.7.14  https://support.google.com/mail/answer/78754 o36sm9782398edc.39 - gsmtp')  

In addition, your email program would have sent you a warning on this login attempt, advising you on potential compromise of your account, or if the login attempt was indeed you, suggesting you to enable less secure apps.

If the credentials are not correct, it will return a different error:

smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at
5.7.8  https://support.google.com/mail/?p=BadCredentials b4sm9037328eda.34 - gsmtp')
  
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.231.15