-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Email] Add SSL support for sending email #5135
Conversation
@thomastech @uzi18 See here for the GH Actions build |
OMG, SSL emails! My email server uses port 587. Any idea when that will be working? |
Not yet, but I'm working on it. Have you tried it yourself? |
Hmm it seems the TLS implementation I currently use either doesn't have the required ciphers included, or maybe it is TLS 1.1 The return code I get when connecting to Gmail is 3, which is So maybe it will work with your mailserver? Anyway I will be looking into updating BearSSL library code. |
@TD-er do you have debug log? |
It seems like for using port 587 you may need to use a client certificate. Still no idea how to do this though.... |
So it doesn't accept connection or no log from transaction? |
Making the connection already fails. When sending via port 465 you get something like this:
|
No luck with the 10/03 and 10/05 test builds. Just a lot of "Timeout while reading input data! str: " messages. Tried both 465 and 587. In case you are interested, I noticed that the browser gets upset when the notification Test button is used. Immediately requires a page reload. And you are sneaky. Timeout now in mS. As a UI setting, I think that seconds would be more natural to the general population. But this is your baby and so I won't complain anymore about using mS resolution for setting timeout seconds. :) |
What I did is just save it first and then try the test button. Can you enable the debug log with the latest GH Actions test build? See here for the interpretation of the error codes: ESPEasy/lib/lib_ssl/tls_mini/src/WiFiClientSecureLightBearSSL.h Lines 205 to 311 in 4845f91
And about the timeout... When connecting to GMail SMTP servers I get error code 3. |
@thomastech Do you have NTP enabled? (or some other method to have the system time set) It should fall-back to the build time of the binary, so I doubt it will really make a difference here... |
Yes, all testing has been with NTP enabled. |
It is Saturday evening, perfect time for debugging, so how can you run out of time? ;) Just watch out when posting the debug logs that you do wipe off the base64-encoded password/username and your email-address. |
I did discuss with some Tasmota devs about it and apparently also Tasmota does not support sending via port 587. So I'm thinking about maybe making a new N003 email plugin which then will use a separate library for all kinds of email-authentications, including of attachments, SSL/TLS/STARTTLS and what not. |
I need to check my ISP to see if port 465 is possible. EDIT: Yes, 465 is supported. |
Here is the log (level debug), my ISP, port 465
|
By the way, I did find you can't (yet) use |
I only entered thomas@myhost.com in the plugin. The included alias is an artifact of the log output. |
@TD-er smtp gmail docs states you can use all three ports for secure connection. |
No success with GMail. Tried ESP_Easy_mega_20241003_collection_B_ESP32_4M316k and ESP_Easy_mega_20241005_collection_B_ESP32_4M316k. Q1. Should both versions work? BTW, I tried the app password without spaces and with spaces. Both fail. Here are the logs:
|
I think this is the reason... |
@thomastech I've built a one-off Collection B build with TLS features enabled for you to test: |
I think there is no reason (yet) not to enable it for all ESP32-xx builds, so I will make a new build where it is enabled for all. |
New build here: https://td-er.nl/ESPEasy/latest/ |
It works! Thanks to Ton's insight. And another thanks to TD-er for building ESP_Easy_mega_20241006_collection_B_ESP32_4M316k. Validated on my ISP's email server and also GMail. Both were a success. This is a game changer. Going forward all my ESP32 devices will be able to eliminate the smtp2go email "bridge." Too bad ESP8266 can't handle the SSL code bloat, since I still have a few of those devices in the wild. |
If there is an ESP32 in the same network, you can also use p2p to send email via those using the |
@TD-er maybe not need a library This is small addition to existing code. |
Hmm can you make a PR for it, so we can test it? |
@TD-er not sure about TLS/SSL stuff, can't find more info about this transaction ;) |
To send via Gmail:
gmail.com
smtp.gmail.com
465
(SSL)<Your email>
<Your Gmail Address>
From Google on SSL/TLS:
ToDo:
This feature is now included in all ESP32-xx 'custom' and 'MAX' builds.