shawwwn/uMail

error when using umail

dimbn opened this issue · 7 comments

hallo shawwn
when using MicroPython v1.22.2 (2024-02-22) umail works properly. when using the latest MicroPython version v1.23.0 (2024-06-02) following error occurs: "ImportError: no module named 'ussl'". how can I solve the problem?
kind regards

Hi. Can you try changing this line to import ssl as ussl and see if it works ?
https://github.com/shawwwn/uMail/blob/26863875d42c612c0f0de15c49163736683fb8f5/umail.py#L28C9-L28C20

It is hard to pinpoint what is wrong but it looks like MbedTLS was not properly configured with your micropython build.

You may need to recompile micropython with new config values according to this comment:
loboris/MicroPython_ESP32_psRAM_LoBo#117 (comment)

this sounds too complicate for me as a newcomer. as a workaround solution I use the former version of MicroPython. so it works properly.
thank you for your support.

I'm encountering the exact same issues as described by dimbn even when using the latest umail.py updated by TheScientist101 along with the recent preview builds of MicroPython for the Raspberry Pi Pico W. Even though this issue report is declared as closed, problem unfortunately still exists...

IDK if this is relevant, but noticed the following changes in the SSL/TLS module from MicroPython v1.22.0 to v1.23.0:

v1.22.0 [https://docs.micropython.org/en/v1.22.0/library/ssl.html] -

ssl.wrap_socket(sock, server_side=False, keyfile=None, certfile=None, cert_reqs=CERT_NONE, cadata=None, server_hostname=None, do_handshake=True)

v1.23.0 [https://docs.micropython.org/en/v1.23.0/library/ssl.html] -

ssl.wrap_socket(sock, server_side=False, key=None, cert=None, cert_reqs=CERT_NONE, cadata=None, server_hostname=None, do_handshake=True)

??

I hit this error, too. It's not a problem with umail but appears to be a deeper flaw in the way that Micropython's urllib handles TLS. It might or might not have to do with the max fragment length issue mentioned above, but every time I tried to use ussl to wrap a socket connection to a TLS SMTP server (I tried several), it throws this error, while it consistently works on port 443 https servers.

The workaround, at least for those with the option, is to use SSL instead of STARTTLS. For Gmail, this is as easy as connecting via port 465 and setting 'ssl=true' when creating the initial smtp object. If you're an Office365 user, you can use a completely unauthenticed port 25 option they call "direct send," but it comes with a lot of limitations.

The firmware version for the Pico W doesn't matter, at least for all of the available options: it fails the same way on every version from 1.20 to 1.23.

For those who experiences this issue and is capable to recompile micropython, can you try changing the constant MBEDTLS_SSL_OUT_CONTENT_LEN to 8192 or even 16384 and report back?

You can find the constant here:
https://github.com/micropython/micropython/blob/288a03625327b025f81bb6d4e7fb76d56343172c/extmod/mbedtls/mbedtls_config_common.h#L62

Reason for this change:
micropython/micropython#5543 (comment)