V
V
Viktor2016-04-12 17:53:14
Python
Viktor, 2016-04-12 17:53:14

How to send an email to Gmail?

I'm trying to send an email to my own gmail account, it gives me this error.

Traceback (most recent call last):
File "D:\Code\Python\Basic\SendTheEmail.py", line 18, in
mail.login('login', 'password')
File "C:\Python33\lib\smtplib .py", line 638, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, b'5.7.9 Application-specific password required. Learn more at\n5.7.9 https://support.google.com /accounts/answer/185833 wl7sm841456lbb.45 - gsmtp')

My code:
import smtplib
content = "Hello from Python"
mail = smtplib.SMTP('smtp.gmail.com', 587)
mail.ehlo()
mail.starttls()
mail.login('[email protected]', 'password')
mail.sendmail('[email protected]', '[email protected]' , 'Hello there')
mail.close()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2016-04-12
@kani339

Have you tried reading https://support.google.com/accounts/answer/185833 ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question