I would like to send an email from a python script. However, when I try run server.login
I receive the following error: smtplib.SMTPAuthenticationError: (535, '5.7.0 (#MBR1212) Incorrect username or password.')
I have tried this both with Gmail and Yahoo accounts. The Gmail error is:
smtplib.SMTPAuthenticationError: (535, '5.7.8 Username and Password not accepted. Learn more at\n5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 u2sm21203448pbs.42 \
- gsmtp')
The Yahoo error is
smtplib.SMTPAuthenticationError: (535, '5.7.0 (#MBR1212) Incorrect username or password.')
The code I am using is the following. Username and password are string variables that represent my correct username and password.
server = smtplib.SMTP('smtp.mail.yahoo.com', 587)
server.ehlo()
server.starttls()
server.login(username, password)
I am using Python 2.7.6 |Anaconda 1.8.0 (x86_64)| (default, May 27 2014, 14:58:54)