I am trying to send an email in Python:html
import smtplib fromaddr = '......................' toaddrs = '......................' msg = 'Spam email Test' username = '.......' password = '.......' server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.login(username, password) server.sendmail(fromaddr, toaddrs, msg) server.quit()
I understand that this is probably not the correct message format.python
Anyways, I get an error:app
C:\.....>python email.py Traceback (most recent call last): File "email.py", line 1, in <module> import smtplib File "C:\.....\Python\lib\smtplib.py", line 47, in <module> import email.utils File "C:\.....\email.py", line 15, in <module> server = smtplib.SMTP('smtp.gmail.com', 587) AttributeError: 'module' object has no attribute 'SMTP'
I don't quite understand what I am doing wrong here... Anything incorrect?dom
NOTE: All the periods are replacements for password/email/file paths/etc.ide