No attribute 'SMTP', error when trying to send email in Python No attribute 'SMTP', error when trying to send email in Python python python

No attribute 'SMTP', error when trying to send email in Python


Python already has an email module. Your script's name is email.py, which is preventing smtplib from importing the built-in email module.

Rename your script to something other than email.py and the problem will go away.


import smtplibconn = smtplib.SMTP('imap.gmail.com',587)conn.ehlo()conn.starttls()conn.login('youremail@gmail.com', 'your_password')conn.sendmail('from@gmail.com','to@gmail.com','Subject: What you like? \n\n Reply Reply Reply')conn.quit()