0
import smtplib

host = 'smtp.gmail.com'
port = 587
username = 'rajinirajadev@gmail.com'
password = '*************'
from_email = username
to_list = ['rajiniraja00@gmail.com']

email_conn = smtplib.SMTP(host,port)
email_conn.ehlo()
email_conn.starttls()
email_conn.login(username, password)
email_conn.sendmail(from_email, to_list, 'that is send via smtplib')
email_conn.quit()

This is the error i am getting. I turned off the two step verification and turned on allow secure apps on gmail.

Traceback (most recent call last):
  File "g:/python files/sending_mail.py", line 13, in <module>
    email_conn.login(username, password)
  File "C:\Users\rajini\AppData\Local\Programs\Python\Python36\lib\smtplib.py", line 730, in login
    raise last_exception
  File "C:\Users\rajini\AppData\Local\Programs\Python\Python36\lib\smtplib.py", line 721, in login
initial_response_ok=initial_response_ok)
  File "C:\Users\rajini\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=AKgnsbtt\n5.7.14 g2A-ALn3B03_YHSMdoFJs18v5jyKCwzi2BirMS2zKuE-fitmN8pDinUQ0-GET0D6hx_SRv\n5.7.14 -6SsaoSCB5IMf6qdHbpG3
79Cm00CyozXK-Ece_1NiViBAQDtSvUmSiJuEhKADmR8xNzsek\n5.7.14 H_Ddosp0mUfQLX2mVl5GmgmGVDaQEZJPAv4YSR8fAZyGydbg1QzFsbHhay2eKo5ttQL6nM\n5.7.14 sgSIHt_sIB4p9AHEWXQU-2J4F-Q5I> Please log in via your web browser and\n5.7.14 then try aga
in.\n5.7.14  Learn more at\n5.7.14  https://support.google.com/mail/answer/78754 186sm583041pgi.11 - gsmtp')
rajini raja
  • 99
  • 3
  • 13

1 Answers1

0

Same problem occurred to me when I was using my gmail account to send emails. i.e. by host = 'smtp.gmail.com'

But when I used my outlook account i.e by host = 'smtp.outlook.com' this problem resolved and I received the message as "(235, b'2.7.0 Authentication successful')"

Conclusion - Gmail spam security was blocking as it considered the script as some untrusted source and sent a mail to my respective account that it has blocked signin-in atempt

shilpi6969
  • 21
  • 1
  • 5