uMail - A lightweight SMTP client for MicroPython
Re: uMail - A lightweight SMTP client for MicroPython
Let me put it this way:
The client will switch to TLS encryption once it sees STARTTLS in server's response, regardless of the status of 'ssl'.
It all depends on server's reply. If you want to enforce a secure connection, then you should let the server to always reply STARTTLS.
Setting 'ssl=True' is just for encrypting the initial connection(i.e., when you connecting to a port that only supports secure connection).
The client will switch to TLS encryption once it sees STARTTLS in server's response, regardless of the status of 'ssl'.
It all depends on server's reply. If you want to enforce a secure connection, then you should let the server to always reply STARTTLS.
Setting 'ssl=True' is just for encrypting the initial connection(i.e., when you connecting to a port that only supports secure connection).
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: uMail - A lightweight SMTP client for MicroPython
I've already understood all that after your first reply.
But what if I have no control over the server and the server doesn't enforce but supports STARTTLS and I want to initiate STARTTLS from the client? With the CPython smtplib module, I would do something like this:
But what if I have no control over the server and the server doesn't enforce but supports STARTTLS and I want to initiate STARTTLS from the client? With the CPython smtplib module, I would do something like this:
Code: Select all
def send_email(from, to, msg, host='localhost', user=None, password=None, ssl=False, starttls=False):
if ssl:
smtp_class = smtplib.SMTP_SSL
port = 465
else:
smtp_class = smtplib.SMTP
port = 587
smtp = smtp_class(host, port)
if starttls:
smtp.starttls()
smtp.ehlo()
...
Re: uMail - A lightweight SMTP client for MicroPython
I see, but adding a 'starttls=True|False' besides 'ssl' would be too confusing for many users.
There is however a hack you can do (without changing the code).
There is however a hack you can do (without changing the code).
Code: Select all
smtp.SMTP('xxx', xx)
# after smtp instance is initialized
code, _ = smtp.cmd('STARTTLS')
assert code == 220
smtp._sock = ussl.wrap_socket(smtp._sock)
# then proceed to login, etc.
...
Last edited by shawwwn on Fri Sep 21, 2018 11:11 am, edited 1 time in total.
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: uMail - A lightweight SMTP client for MicroPython
Ok, thanks for the workaround.
I don't think that a separate option for starttls would be too confusing, but opinions differ
I don't think that a separate option for starttls would be too confusing, but opinions differ
Re: uMail - A lightweight SMTP client for MicroPython
Good job shawwwn. Your lib works perfect!
Thank you
Thank you
Re: uMail - A lightweight SMTP client for MicroPython
Using a Pycom GPy board these are my results...
GoDaddy ('smtpout.secureserver.net', 465, ssl=True) works
Offie365 ('smtp.office365.com', 587, ssl=xxxx)
# SSL True = OSError: [Errno 113] EHOSTUNREACH
# SSL False = AssertionError: auth error 535
Outlook Mail ('smtp-mail.outlook.com', 587, ssl=xxxx)
# SSL True = OSError: [Errno 113] EHOSTUNREACH
# SSL False = AssertionError: auth error 535
don't want to use "Allow less secure apps"
G mail ('smtp.gmail.com', 465, ssl=xxxx)
# SSL True = OSError: [Errno 113] EHOSTUNREACH
# SSL False = OSError: [Errno 113] EHOSTUNREACH
anyone able to connect to these email servers?
or other servers?
What am I missing or not understanding.
GoDaddy ('smtpout.secureserver.net', 465, ssl=True) works
Offie365 ('smtp.office365.com', 587, ssl=xxxx)
# SSL True = OSError: [Errno 113] EHOSTUNREACH
# SSL False = AssertionError: auth error 535
Outlook Mail ('smtp-mail.outlook.com', 587, ssl=xxxx)
# SSL True = OSError: [Errno 113] EHOSTUNREACH
# SSL False = AssertionError: auth error 535
don't want to use "Allow less secure apps"
G mail ('smtp.gmail.com', 465, ssl=xxxx)
# SSL True = OSError: [Errno 113] EHOSTUNREACH
# SSL False = OSError: [Errno 113] EHOSTUNREACH
anyone able to connect to these email servers?
or other servers?
What am I missing or not understanding.
-
- Posts: 13
- Joined: Thu Nov 03, 2016 10:12 pm
Re: uMail - A lightweight SMTP client for MicroPython
I tried to use this great looking library today, unfortunately it had an array index issue on line 30 of umail.py
I submitted an issue on the github
https://github.com/shawwwn/uMail/issues/4
I am using an esp32 (devkitc), latest micropython, upycraft ide.
I would appreciate any suggestions.
I submitted an issue on the github
https://github.com/shawwwn/uMail/issues/4
I am using an esp32 (devkitc), latest micropython, upycraft ide.
I would appreciate any suggestions.
-
- Posts: 13
- Joined: Thu Nov 03, 2016 10:12 pm
Re: uMail - A lightweight SMTP client for MicroPython
Great library, fantastic support.
My bad, I had connecting to my wifi commented out.
My bad, I had connecting to my wifi commented out.
Re: uMail - A lightweight SMTP client for MicroPython
Hi I am new to Micropython running on ESP32 port. I would like to know how to install this umail module onto the chip. I tried upip to install package but with no avail from the getlib repository. Please advice..
Re: uMail - A lightweight SMTP client for MicroPython
Hi all,
gotten a bit further and uploaded umail.py into the ESP32 and ran the import command
during this line,
smtp = umail.SMTP('smtp.gmail.com', 465, ssl=True)
it reported:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SMTP'
did i do something wrong? Please advice... Thanks.
gotten a bit further and uploaded umail.py into the ESP32 and ran the import command
during this line,
smtp = umail.SMTP('smtp.gmail.com', 465, ssl=True)
it reported:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SMTP'
did i do something wrong? Please advice... Thanks.