Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to use with MailerSend, getting RECORD_OVERFLOW #30

Open
DangRock opened this issue Oct 22, 2024 · 7 comments
Open

Trying to use with MailerSend, getting RECORD_OVERFLOW #30

DangRock opened this issue Oct 22, 2024 · 7 comments

Comments

@DangRock
Copy link

DangRock commented Oct 22, 2024

Anyone get this working with a service like MailerSend? I get OSError: (-257, 'RECORD_OVERFLOW').

Code:

    import time
    import umail
    import network

    server = 'smtp.mailersend.net'
    un = '########'
    pw = '########'
    tlsPort = 587
    
    smtp = umail.SMTP(server, tlsPort, ssl=False, username=un, password=pw)

Result:

TLS buffer overflow, record size: 8307 (+5)

Traceback (most recent call last):
  File "<stdin>", line 49, in <module>
  File "<stdin>", line 26, in sendEmail
  File "umail.py", line 36, in __init__
  File "ssl.py", line 1, in wrap_socket
  File "ssl.py", line 1, in wrap_socket
OSError: (-257, 'RECORD_OVERFLOW')

Appreciate any guidance. I have an SMTP server running on my Synology and I get the same result when using TLS. TLS is required for MailerSend (no SSL port option).

@shawwwn
Copy link
Owner

shawwwn commented Oct 24, 2024

Possibly related to issue #28 .

Sorry you encounter the error, however the problem behind it is beyond the scope of uMail (nothing I can do to fix it).
There are essentially three options you can try:

  1. Start with SSL enabled (if possible).
  2. Recompile micropython with a larger MBEDTLS_SSL_OUT_CONTENT_LEN.
  3. Try a different version of MicroPython.

@DangRock
Copy link
Author

The weird thing is some of the mail relays that do have SSL (MailJet, SendGrid) still return the TLS error. I'm thinking they have some kind of fall-back and are actually pushing SSL to TLS. Seems like the only ones I've found that actually use SSL are will work (if I could authenticate) are gmail and yahoo. Gmail got rid of their app password setup, and apparently I have to wait a while before yahoo will let me generate an app password.

I've tried MicroPython 1.22 with no luck. I'm using Thonny, so I need to figure out how to go further back than 1.22.

I'm going to look into how to recompile MicroPython with the larger CONTENT_LEN setting. I've read about that possibly fixing it previously but I'm not sure how to do it yet.

Will keep you updated on my progress.

@shawwwn
Copy link
Owner

shawwwn commented Oct 24, 2024

The weird thing is some of the mail relays that do have SSL (MailJet, SendGrid) still return the TLS error.

You are right. Server can force a TLS connection from a non-SSL connection via the command STARTTLS, hence the TLS error.

@DangRock
Copy link
Author

No dice. I was able to setup the MicroPython firmware repo and a Linux VM to run the ESP8266 port firmware build. Updated the file you referenced to 16384 and rebuild the firmware, flashed, and still same issue. I'm hoping my Yahoo account will start working and I can get an app password from there to see if it'll work like gmail previously did.

@shawwwn
Copy link
Owner

shawwwn commented Oct 24, 2024

ESP8266's port of micropython uses axTLS, not MbedTLS.

You may need to edit the the port's Makefile to increase its TLS buffer size, set -DRT_EXTRA to a bigger value.

https://github.com/micropython/micropython/blob/18c9abc32930728d0403d8c13994adc3cabba8db/ports/esp8266/Makefile#L51

@DangRock
Copy link
Author

Tried setting it to 8196 and 16384, but still the same error.

TLS buffer overflow, record size: 8275 (+5)
Traceback (most recent call last):
  File "<stdin>", line 64, in <module>
  File "<stdin>", line 41, in sendEmail
  File "umail.py", line 36, in __init__
  File "ssl.py", line 1, in wrap_socket
  File "ssl.py", line 1, in wrap_socket
OSError: (-257, 'RECORD_OVERFLOW')

@shawwwn
Copy link
Owner

shawwwn commented Oct 25, 2024

Interesting.
It appears the problem was related to micropython/micropython#3279 however the fix is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants