@Vikram
Have given it a try against gmail servers. It connects to the smtp server ok but the next write_and_get_response (I believe) seems to fail returning -1. The log is (have removed the personal details with XXXX
)....
Code: Select all
load:0x3fff0018,len:4
load:0x3fff001c,len:7212
load:0x40078000,len:14176
load:0x40080400,len:4480
entry 0x400806f0
I (71) boot: Chip Revision: 1
I (72) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot: ESP-IDF v4.1-dev-1086-g93a8603-dirty 2nd stage bootloader
I (39) boot: compile time 18:02:22
I (40) boot: Enabling RNG early entropy source...
I (45) boot: SPI Speed : 40MHz
I (49) boot: SPI Mode : DIO
I (53) boot: SPI Flash Size : 2MB
I (58) boot: Partition Table:
I (61) boot: ## Label Usage Type ST Offset Length
I (68) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (76) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (83) boot: 2 factory factory app 00 00 00010000 00100000
I (91) boot: End of partition table
I (95) boot_comm: chip revision: 1, min. application chip revision: 0
I (102) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2758c (161164) map
I (169) esp_image: segment 1: paddr=0x000375b4 vaddr=0x3ffb0000 size=0x032f8 ( 13048) load
I (175) esp_image: segment 2: paddr=0x0003a8b4 vaddr=0x40080000 size=0x00400 ( 1024) load
I (176) esp_image: segment 3: paddr=0x0003acbc vaddr=0x40080400 size=0x0535c ( 21340) load
I (194) esp_image: segment 4: paddr=0x00040020 vaddr=0x400d0020 size=0x847b8 (542648) map
I (390) esp_image: segment 5: paddr=0x000c47e0 vaddr=0x4008575c size=0x0f864 ( 63588) load
I (430) boot: Loaded app from partition at offset 0x10000
I (430) boot: Disabling RNG early entropy source...
I (431) cpu_start: Pro cpu up.
I (434) cpu_start: Application information:
I (439) cpu_start: Project name: smtp_client
I (444) cpu_start: App version: 1
I (449) cpu_start: Compile time: Feb 3 2020 18:39:26
I (455) cpu_start: ELF file SHA256: 04d1e4803aca4d1a...
I (461) cpu_start: ESP-IDF: v4.1-dev-1086-g93a8603-dirty
I (467) cpu_start: Starting app cpu, entry point is 0x40081254
I (0) cpu_start: App cpu up.
I (478) heap_init: Initializing. RAM available for dynamic allocation:
I (485) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (491) heap_init: At 3FFB9368 len 00026C98 (155 KiB): DRAM
I (497) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (503) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (510) heap_init: At 40094FC0 len 0000B040 (44 KiB): IRAM
I (516) cpu_start: Pro cpu start user code
I (534) spi_flash: detected chip: generic
I (535) spi_flash: flash io: dio
W (535) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (545) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (631) wifi: wifi driver task: 3ffc0c54, prio:23, stack:3584, core=0
I (631) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (631) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (661) wifi: wifi firmware version: a44d1c6
I (661) wifi: config NVS flash: enabled
I (661) wifi: config nano formating: disabled
I (661) wifi: Init dynamic tx buffer num: 32
I (661) wifi: Init data frame dynamic rx buffer num: 32
I (671) wifi: Init management frame dynamic rx buffer num: 32
I (671) wifi: Init management short buffer num: 32
I (681) wifi: Init static rx buffer size: 1600
I (681) wifi: Init static rx buffer num: 10
I (691) wifi: Init dynamic rx buffer num: 32
I (691) example_connect: Connecting to XXXXX...
I (781) phy: phy_version: 4180, cb3948e, Sep 12 2019, 16:39:13, 0, 0
I (781) wifi: mode : sta (84:0d:8e:d2:40:b8)
I (791) example_connect: Waiting for IP
I (911) wifi: new:<1,1>, old:<1,0>, ap:<255,255>, sta:<1,1>, prof:1
I (1661) wifi: state: init -> auth (b0)
I (1661) wifi: state: auth -> assoc (0)
I (1671) wifi: state: assoc -> run (10)
I (1721) wifi: connected with XXXXX, aid = 5, channel 1, 40U, bssid = 00:f2:01:18:c9:c0, security type: 3, phy: bgn, rssi: -38
I (1721) wifi: pm start, type: 1
I (1751) wifi: AP's beacon interval = 102400 us, DTIM period = 3
I (2621) esp_netif_handlers: sta ip: XXXXXXX, mask: 255.255.255.0, gw: XXXXXXX
I (2621) example_connect: Got IP event!
I (3621) example_connect: Got IPv6 event!
I (3621) example_connect: Connected to XXXXXX
I (3621) example_connect: IPv4 address: XXXXXX
I (3621) example_connect: IPv6 address: XXXXXX
I (3631) smtp_example: Seeding the random number generator
I (3641) smtp_example: Loading the CA root certificate...
I (3651) smtp_example: Setting hostname for TLS session...
I (3651) smtp_example: Setting up the SSL/TLS structure...
I (3661) smtp_example: Connecting to smtp.gmail.com:465...
I (3701) smtp_example: Connected.
E (13841) smtp_example: mbedtls_net_recv failed with error -0x0
E (13841) smtp_example: Last error was: -0x1 - UNKNOWN ERROR CODE (0001)
Any ideas? If you need me to do any further testing etc. let me know.
In terms of feedback on the code example, I has some thoughts to make it a bit easier for others to follow.
1. The call to example_connect() I assume connects to the WiFi but couldn't see where this is defined and how it gets the SSID and Password from the config file. Not sure how to translate that into my code with the correct WiFi setup
2. All the connection to the SMTP server and the sending of the email etc. is done it 1 function. Would be better to split them into separate ones to see how each bit works. E.g. if I have to send several emails (e.g. hourly to send data) can I connect once and then every hour just do the send bits?
3. I don't think this example receives emails but same comment as 2. Would be good to have that as a separate loop to split it out
Thanks
Lee.