Page 2 of 2

Re: uMail - A lightweight SMTP client for MicroPython

Posted: Fri Sep 21, 2018 10:22 am
by shawwwn
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).

Re: uMail - A lightweight SMTP client for MicroPython

Posted: Fri Sep 21, 2018 10:41 am
by SpotlightKid
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:

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

Posted: Fri Sep 21, 2018 10:53 am
by shawwwn
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).

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.
...

Re: uMail - A lightweight SMTP client for MicroPython

Posted: Fri Sep 21, 2018 11:02 am
by SpotlightKid
Ok, thanks for the workaround.

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

Posted: Sat Jan 05, 2019 11:16 am
by bakrag
Good job shawwwn. Your lib works perfect!
Thank you

Re: uMail - A lightweight SMTP client for MicroPython

Posted: Fri Jun 28, 2019 4:24 pm
by PM-TPI
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.

Re: uMail - A lightweight SMTP client for MicroPython

Posted: Wed Sep 04, 2019 12:41 am
by mikronauts
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.

Re: uMail - A lightweight SMTP client for MicroPython

Posted: Wed Sep 04, 2019 7:17 pm
by mikronauts
Great library, fantastic support.

My bad, I had connecting to my wifi commented out.

Re: uMail - A lightweight SMTP client for MicroPython

Posted: Fri Oct 18, 2019 12:41 am
by taropal
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

Posted: Sun Oct 20, 2019 2:55 am
by taropal
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.