1
I am learning to send email in python and I am facing several problems. One of them is already in the import of the smtplib module. My code is this:
from smtplib import SMTP
smtp=SMTP('smtp.live.com',587)
smtp.starttls()
smtp.login('[email protected]','senha')
msg='ola mundo'
smtp.sendmail('[email protected]',['[email protected]'],msg)
smtp.quit()
This script generates the following error:
Traceback (most recent call last):
File "C:\Users\Benedito\Desktop\email.py", line 1, in <module>
from smtplib import SMTP
File "C:\Users\Benedito\AppData\Local\Programs\Python\Python35- 32\lib\smtplib.py", line 47, in <module>
import email.utils
File "C:\Users\Benedito\Desktop\email.py", line 1, in <module>
from smtplib import SMTP
ImportError: cannot import name 'SMTP'
From what I understand, the error treats the smtplib module as if it did not have the SMTP method in it. However, when I run the direct import on the Python command line, this import error does not occur. Because it is giving error when running a script and is not giving error when running writing line by line in the python command line?
I am on Windows 8 and use Python 3.5.2