By the way: In the announcement I read that the Blynk library fully supports HTTPS calls. Is that so? Do they have a working MicroPython implementation for HTTPS?Ferretproof wrote:That would be award winning, especially when it also supports HTTPS.
(tell me when I ask too much )
Sending email
Re: Sending email
pyBoard v1.0 + LCD32MKv1.0 | WiPy + Expansion Board | GitHub
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: Sending email
It says that it supports SSL. Blynk doesn't use HTTPS, they have their own protocol build on top of sockets. Check the library:
https://github.com/wipy/wipy/blob/maste ... lynkLib.py
https://github.com/wipy/wipy/blob/maste ... lynkLib.py
Re: Sending email
It seems they're using the ussl module which is not yet mentioned in the documentation.danicampora wrote:It says that it supports SSL. Blynk doesn't use HTTPS, they have their own protocol build on top of sockets. Check the library
Is this available on the WiPy, too?
pyBoard v1.0 + LCD32MKv1.0 | WiPy + Expansion Board | GitHub
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: Sending email
The link you provide is the one for the pyboard docs, the one for the WiPy is (the one on the sticky post and on the KS update):
http://micropython.org/resources/docs/en/latest/wipy/
And yes, ssl is documented:
http://micropython.org/resources/docs/e ... /ussl.html
Cheers,
Daniel
http://micropython.org/resources/docs/en/latest/wipy/
And yes, ssl is documented:
http://micropython.org/resources/docs/e ... /ussl.html
Cheers,
Daniel
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: Sending email
That's a funny question because that Blynk library was written by us (with the invaluable help of Volodymyr Shymanskyy), specially for the WiPy. It's also a fact the the WiPy is the only MCU platform that can connect to the Blynk servers using ssl...Is this available on the WiPy, too?
Re: Sending email
Okay, my bad. Sorry. I somehow ended up on the main MicroPython documentation.danicampora wrote:The link you provide is the one for the pyboard docs, the one for the WiPy is (the one on the sticky post and on the KS update):
http://micropython.org/resources/docs/en/latest/wipy/
And yes, ssl is documented:
http://micropython.org/resources/docs/e ... /ussl.html
Is it planned to add the WiPy-specific documentation to the main MicroPython docs - like it is for the pyBoard?
pyBoard v1.0 + LCD32MKv1.0 | WiPy + Expansion Board | GitHub
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: Sending email
Hi!
I have a first version of the smtplib.py file, it's compact and doesn't need any external libraries. Attached here. Please test and let us know your results, with your help we can make it good enough to make it part of the official library. Examples:
Following scripts assume an already established internet connection
Without TLS/SSL:
With TLS/SSL:
The WiPy doesn't support turning a standard socket into a secure one on the fly, it needs to be secure from the very beginning, therefore there's no need to call , but on the other hand, when creating the stmp instance with tls=True (default value), the correct secure port must be used (465 in the case of gmail).
Remark about gmail: Since sometime ago gmail (and also other popular mail servers) require OAuth2 to authenticate unless you allow "non secure apps" to access your account. OAuth2 is out of the scope of smtplib and I really don't know how to deal with it yet. Details can be found here: https://support.google.com/accounts/ans ... 0255?hl=en
Cheers,
Daniel
I have a first version of the smtplib.py file, it's compact and doesn't need any external libraries. Attached here. Please test and let us know your results, with your help we can make it good enough to make it part of the official library. Examples:
Following scripts assume an already established internet connection
Without TLS/SSL:
Code: Select all
to = 'recipient@mail.com'
gmail_user = 'some.user@wipy.io'
gmail_pwd = 'password'
smtpserver = smtplib.SMTP("smtp02.hostnet.nl", 587, tls=False)
smtpserver.helo()
smtpserver.login(gmail_user, gmail_pwd)
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject: Email from the WiPy \n'
msg = header + '\n Hi, \n this is The WiPy emailing ;-) \n\n Cheers, \n The WiPy'
smtpserver.sendmail(gmail_user, to, msg)
smtpserver.close()
Code: Select all
to = 'recipient@mail.com'
gmail_user = 'some.user@gmail.com'
gmail_pwd = 'password'
smtpserver = smtplib.SMTP("smtp.gmail.com", 465)
smtpserver.helo()
smtpserver.login(gmail_user, gmail_pwd)
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject: Email from the WiPy \n'
msg = header + '\n Hi, \n this is The WiPy emailing ;-) \n\n Cheers, \n The WiPy'
smtpserver.sendmail(gmail_user, to, msg)
smtpserver.close()
Code: Select all
smtpserver.starttls()
Remark about gmail: Since sometime ago gmail (and also other popular mail servers) require OAuth2 to authenticate unless you allow "non secure apps" to access your account. OAuth2 is out of the scope of smtplib and I really don't know how to deal with it yet. Details can be found here: https://support.google.com/accounts/ans ... 0255?hl=en
Cheers,
Daniel
- Attachments
-
- smtplib.zip
- (2.68 KiB) Downloaded 4628 times
Re: Sending email
Looks good Daniel! May I suggest that you define an SMTP_SSL class (derived from SMTP) that is used to create secure connections, rather than the tls argument to the constructor of the SMTP class? That's how CPython does it and will make the code much more compatible with Python on the desktop. Also, it would allow you to provide a default SSL port of 465 when port is not given in the SMTP_SSL constructor.
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: Sending email
Yes, that's a good idea, thanks Damien!May I suggest that you define an SMTP_SSL class (derived from SMTP) that is used to create secure connections, rather than the tls argument to the constructor of the SMTP class?