[quote=henkoegema post_id=30530 time=1538143662 user_id=4304]
I'm trying to use the examples in this thread to send e-mail from a Wemos D1 mini ESP8266 loaded with micropython.
It already fails at the first line: >>>import smtplib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'smtplib'
Q: how to import module smtplib ? (or module curl ?)
[/quote]
I made small progress.
After downloading from:
https://github.com/micropython/micropython-lib I could import smtplib. (but not module curl)
I'm trying this example:
*********************************************************************************************
>>> import smtplib
>>> efrom = '
me@yahoo.com'
>>> eto = '
you@gmail.com'
>>> header = 'To: {} \nFrom: {} \nSubject: Email from my WiPy\n\n'.format(efrom, eto)
>>> msg = header + 'Hi,\nThis is the WiPy emailing
\n'
>>> smtpserver = smtplib.SMTP('smtp.mail.yahoo.com', 465) <---------------------
>>> smtpserver.helo()
(250, b'smtp.mail.yahoo.com')
>>> smtpserver.login(efrom, 'ypassword')
(235, b'2.0.0 OK')
>>> smtpserver.sendmail(efrom, eto, msg)
{}
>>> smtpserver.close()
***************************************************************************************************
Here it fails:
>>> smtpserver = smtplib.SMTP('smtp.mail.gmail.com', 465)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SMTP' <---------------------