ESP32-EVB SMTP connection fails over onboard Ethernet only

Started by atlantisguru, March 15, 2020, 06:21:52 PM

Previous topic - Next topic

atlantisguru

I have an Olimex ESP32-EVB board.
I would like to send email over Ethernet but it fails when Identification (not authentication) comes. The TCP connection suddenly closed by the board. With WiFi it works perfectly, but i dont want to use WiFi.
All credentials are ok.
Tried with multiple SMTP server.
Tried with DHCP, fix IP.
DNS set manually. Hostname set manually. Using port 587.
Arduino IDE 1.8.12, ESP32 core version 1.0.4.
Email library: mobizt/ESP32-MAil-Client

Arduino debug messages:

15:18:49.915 -> Connecting to SMTP server...
15:18:49.915 -> [DEBUG] - INFO: connecting to SMTP server...
15:18:49.915 -> [DEBUG] - smtp.gmail.com
15:18:49.915 -> [DEBUG] - 587
15:18:49.915 -> [DEBUG] - INFO: cleaning SSL connection
15:18:49.915 -> [DEBUG] - INFO: starting socket
15:18:49.977 -> [DEBUG] - INFO: connecting to Server...
15:18:50.024 -> [DEBUG] - INFO: server connected
15:18:50.024 -> [DEBUG] - INFO: begin STARTTLS handshake
15:18:51.019 -> [DEBUG] - 220 smtp.gmail.com ESMTP z22sm16371993wmi.1 - gsmtp
15:18:51.019 ->
15:18:51.019 -> ⸮!Pk
15:18:51.019 -> [DEBUG] - INFO: send SMTP command extended HELO
15:18:52.013 -> [DEBUG] - 250-smtp.gmail.com at your service, [5.63.214.69]
15:18:52.013 -> 250-SIZE 35882577
15:18:52.091 -> 250-8BITMIME
15:18:52.091 -> 250-STARTTLS
15:18:52.091 -> 250-ENHANCEDSTATUSCODES
15:18:52.091 -> 250-PIPELINING
15:18:52.091 -> 250-CHUNKING
15:18:52.091 -> 250 SMTPUTF8
15:18:52.091 ->
15:18:52.091 -> [DEBUG] - INFO: send STARTTLS protocol command
15:18:53.062 -> [DEBUG] - 220 2.0.0 Ready to start TLS
15:18:53.062 ->
15:18:53.062 -> [DEBUG] - INFO: seeding the random number generator
15:18:53.062 -> [DEBUG] - INFO: setting up the SSL/TLS structure...
15:18:53.062 -> [DEBUG] - INFO: setting hostname for TLS session...
15:18:53.062 -> [DEBUG] - INFO: performing the SSL/TLS handshake...
15:18:54.002 -> [DEBUG] - INFO: verifying peer X.509 certificate...
15:18:54.002 -> [DEBUG] - INFO: certificate verified
15:18:54.002 -> [DEBUG] - INFO: smtp server connected
15:18:54.002 -> Identification...
15:18:54.002 -> [DEBUG] - INFO: send smtp HELO command
15:18:54.002 -> Error, identification failed                               //<- WiFi can pass through here
15:18:54.002 -> [DEBUG] - ERROR: identification failed
15:18:54.002 -> [DEBUG] - INFO: cleaning SSL connection
15:18:54.002 -> Error sending Email, identification failed

Wireshark:

3033 1591.392626 192.168.137.2 108.177.15.108 TCP 58 52839 → 587 [SYN] Seq=0 Win=5744 Len=0 MSS=1436
3034 1591.451031 108.177.15.108 192.168.137.2 TCP 58 587 → 52839 [SYN, ACK] Seq=0 Ack=1 Win=62920 Len=0 MSS=1430
3035 1591.451720 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [ACK] Seq=1 Ack=1 Win=22976 Len=0
3036 1591.510841 108.177.15.108 192.168.137.2 SMTP 107 S: 220 smtp.gmail.com ESMTP n1sm40021609wrj.77 - gsmtp
3037 1591.510913 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [ACK] Seq=1 Ack=54 Win=22976 Len=0
3038 1591.920478 192.168.137.1 224.0.0.251 MDNS 102 Standard query response 0x0000 A, cache flush 192.168.137.1
3039 1592.452915 192.168.137.2 108.177.15.108 SMTP 65 C: EHLO DUDE
3040 1592.540947 108.177.15.108 192.168.137.2 TCP 54 587 → 52839 [ACK] Seq=54 Ack=12 Win=62920 Len=0
3041 1592.548404 108.177.15.108 192.168.137.2 SMTP 221 S: 250-smtp.gmail.com at your service, [5.63.214.69] | SIZE 35882577 | 8BITMIME | STARTTLS | ENHANCEDSTATUSCODES | PIPELINING | CHUNKING | SMTPUTF8
3042 1592.548522 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [ACK] Seq=12 Ack=221 Win=22976 Len=0
3043 1593.462134 192.168.137.2 108.177.15.108 SMTP 64 C: STARTTLS
3044 1593.520641 108.177.15.108 192.168.137.2 SMTP 84 S: 220 2.0.0 Ready to start TLS
3045 1593.520684 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [ACK] Seq=22 Ack=251 Win=22976 Len=0
3046 1594.475617 192.168.137.2 108.177.15.108 TLSv1 357 Client Hello
3047 1594.551024 108.177.15.108 192.168.137.2 SSL 152 [TCP Previous segment not captured] , Continuation Data
3048 1594.551408 108.177.15.108 192.168.137.2 TCP 1484 [TCP Out-Of-Order] 587 → 52839 [ACK] Seq=251 Ack=325 Win=63784 Len=1430
3049 1594.553589 192.168.137.2 108.177.15.108 TCP 54 [TCP Dup ACK 3045#1] 52839 → 587 [ACK] Seq=325 Ack=251 Win=22976 Len=0
3050 1594.553722 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [ACK] Seq=325 Ack=1681 Win=22976 Len=0
3051 1594.558306 108.177.15.108 192.168.137.2 TCP 1484 [TCP Out-Of-Order] 587 → 52839 [ACK] Seq=1681 Ack=325 Win=63784 Len=1430
3052 1594.558355 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [ACK] Seq=325 Ack=3209 Win=22976 Len=0
3053 1594.925986 192.168.137.1 224.0.0.251 MDNS 93 Standard query response 0x0000 A, cache flush 192.168.8.101
3054 1595.313210 192.168.137.2 108.177.15.108 TLSv1.2 129 Client Key Exchange
3055 1595.317151 192.168.137.2 108.177.15.108 TLSv1.2 60 Change Cipher Spec
3056 1595.318389 192.168.137.2 108.177.15.108 TLSv1.2 99 Encrypted Handshake Message
3057 1595.380724 108.177.15.108 192.168.137.2 TCP 54 587 → 52839 [ACK] Seq=3209 Ack=406 Win=63784 Len=0
3058 1595.388265 108.177.15.108 192.168.137.2 TLSv1.2 346 New Session Ticket, Change Cipher Spec, Encrypted Handshake Message
3059 1595.401198 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [ACK] Seq=451 Ack=3501 Win=22976 Len=0
3060 1595.416261 192.168.137.2 108.177.15.108 TLSv1.2 92 Application Data
3061 1595.416793 192.168.137.2 108.177.15.108 TLSv1.2 85 Application Data
3062 1595.422297 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [FIN, ACK] Seq=520 Ack=3501 Win=22976 Len=0
3063 1595.470711 108.177.15.108 192.168.137.2 TCP 54 587 → 52839 [ACK] Seq=3501 Ack=520 Win=63784 Len=0
3064 1595.478523 108.177.15.108 192.168.137.2 TLSv1.2 119 Application Data
3065 1595.478549 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [ACK] Seq=521 Ack=3566 Win=22976 Len=0
3066 1595.479195 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [RST, ACK] Seq=521 Ack=3566 Win=5744 Len=0
3067 1595.490816 108.177.15.108 192.168.137.2 TCP 54 587 → 52839 [FIN, ACK] Seq=3566 Ack=521 Win=63784 Len=0
3068 1595.492336 192.168.137.2 108.177.15.108 TCP 54 52839 → 587 [RST] Seq=521 Win=0 Len=0

Any suggestion where to start? (Espressif forum - no answer, ESP32 github issue - no answer, StackOverflow - no answer)

LubOlimex

I can't see your issue here:

https://github.com/mobizt/ESP32-Mail-Client/issues

The guy that wrote the SMTP client would know best.
Technical support and documentation manager at Olimex

atlantisguru

Thank you for your response!

Here is my issue:
https://github.com/espressif/arduino-esp32/issues/3813

We discussed with the creator of the Mail Client library that the problem is not library related, because it works perfect with WiFi.
SMTP connection fails only on ethernet.
Maybe something MTU problem, but there is no option to change anything about the ethernet adapter.
In the debug there is a line ("⸮!Pk") what is sent back by any SMTP server. When i connected with WiFi this line is almost a 100 character.
This is the reason why i am thinking about something TCP packet handling problem with the ethernet adapter.

JohnS

If it's a TCP-related problem then it's whoever maintains that code and any code it relies on...

John

atlantisguru

Thank you for try to help me.
In the last week that was the only thing i heard a lot every forum except espressif where no response at all.