ESP32 IDF smtp (Simple Mail Transfer Protocol) support

serkam
Posts: 7
Joined: Thu Nov 10, 2016 1:31 pm

ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby serkam » Tue Jun 18, 2019 7:06 pm

Hi

Does ESP32 IDF support SMTP (Simple Mail Transfer Protocol)?
If positive, where can I find an example?
I am developing an IoT device that must send an email for a specific user.

Thank you.
Sergio Kamakura

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby leenowell » Sat Feb 01, 2020 5:10 pm

@serkam Did you manage to get anywhere with this? I have the same requirement and after hours of searching have drawn a blank. I have found a few Arduino libraries but nothing using the native esp IDF.

ESP_Vikram
Posts: 24
Joined: Fri Nov 23, 2018 12:07 pm

Re: ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby ESP_Vikram » Mon Feb 03, 2020 6:29 am

Does ESP32 IDF support SMTP (Simple Mail Transfer Protocol)?
Hello serkam and leenowell, we are working on adding SMTP client as an example in IDF.

Will take some time to release final version.

Meanwhile, I am attaching here working preview copy.

Final version will be very close to this.

PFA.

Thanks and regards,
Vikram
Attachments
smtp_client.zip
(41.08 KiB) Downloaded 629 times

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby leenowell » Mon Feb 03, 2020 9:34 am

@Vikram

Thanks very much for this. I have been searching around a lot for an IDF based example and it is difficult to find (most are Arduino based). I have found one and managed to get it working but now struggling with a very odd issue (just posted it on the forum).

How complete / working is the example you have attached ? If it can at least reliably send an email, I am happy to switch to this and do some testing for you.

ESP_Vikram
Posts: 24
Joined: Fri Nov 23, 2018 12:07 pm

Re: ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby ESP_Vikram » Mon Feb 03, 2020 1:06 pm

@leenowell Yes,
It should work as it is.
Also, there is the support for attachments if you are interested.
Only caveat is...I have seen gmail flags login as insecure as it expect OAUTH login (Although the implemented one happen over tls!), and you may need to change settings to allow insecure login. Please take a look.

Thanks.

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby leenowell » Mon Feb 03, 2020 7:33 pm

@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.

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby leenowell » Mon Feb 03, 2020 8:10 pm

@Vikram

Found the issue...I used the SSL port number (465) rather than the TLS port number (587). Looks like the error message was not ideal :). In trouble shooting it, I did have another suggestion. Since the error numbers are < 0 , printing the hex value is not ideal as it doesn't match the numbers in the header file to translate it. If you print ret*-1 instead then it makes it easier to correlate with numbers in the header file. Admittedly you print the error message out which it corresponds to but if this case it was an "unknown" error.

Would appreciate your thoughts on my earlier questions too.

Thanks again for posting this.

Lee.

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby leenowell » Mon Feb 03, 2020 9:38 pm

@Vikram

I have done some further testing and found a couple of bugs (?).
1. The filename in the code where you upload the attachment has the wrong filename. It references test_image instead of sample_image.
2. Having correct this, it seems to upload the image but the received email has the attachment but it is 0 bytes. I did a bit of debugging and updated the while loop to add further debugging

Code: Select all

	int nAcc = 0;
    /* Image contents... */
    const uint8_t *offset = sample_image_jpg_start;
    while (offset < sample_image_jpg_end) {
        int read_bytes = MIN(((sizeof (base64_buffer) - 1) / 4) * 3, sample_image_jpg_end - offset);
        ret = mbedtls_base64_encode((unsigned char *) base64_buffer, sizeof(base64_buffer),
                                    &base64_len, (unsigned char *) offset, read_bytes);
        nAcc+=read_bytes;
        if (ret != 0) {
            ESP_LOGE(TAG, "Error in mbedtls encode! ret = %d\n", ret);
            goto exit;
        }
        offset += read_bytes;
        len = snprintf((char *) buf, BUF_SIZE, "%s\r\n", base64_buffer);
        ret = write_ssl_data(&ssl, (unsigned char *) buf, len);
        ESP_LOGE("LEE", "Read bytes [%d] Acc [%d] Ret [%d] Len[%d]", read_bytes, nAcc, ret, len);
    }

    len = snprintf((char *) buf, BUF_SIZE, "\n--XYZabcd1234\n");
    ret = write_ssl_data(&ssl, (unsigned char *) buf, len);
    ESP_LOGE("LEE", "Ret [%d] Len[%d]", ret, len);
The output of my extra logging is...

Code: Select all

E (5051) LEE: Read bytes [93] Acc [93] Ret [0] Len[126]
E (5051) LEE: Read bytes [93] Acc [186] Ret [0] Len[126]
E (5051) LEE: Read bytes [93] Acc [279] Ret [0] Len[126]
E (5061) LEE: Read bytes [93] Acc [372] Ret [0] Len[126]
E (5071) LEE: Read bytes [93] Acc [465] Ret [0] Len[126]
E (5071) LEE: Read bytes [93] Acc [558] Ret [0] Len[126]
E (5081) LEE: Read bytes [93] Acc [651] Ret [0] Len[126]
E (5081) LEE: Read bytes [93] Acc [744] Ret [0] Len[126]
E (5091) LEE: Read bytes [93] Acc [837] Ret [0] Len[126]
E (5091) LEE: Read bytes [93] Acc [930] Ret [0] Len[126]
E (5101) LEE: Read bytes [93] Acc [1023] Ret [0] Len[126]
E (5111) LEE: Read bytes [93] Acc [1116] Ret [0] Len[126]
E (5111) LEE: Read bytes [93] Acc [1209] Ret [0] Len[126]
E (5121) LEE: Read bytes [93] Acc [1302] Ret [0] Len[126]
E (5121) LEE: Read bytes [93] Acc [1395] Ret [0] Len[126]
E (5131) LEE: Read bytes [93] Acc [1488] Ret [0] Len[126]
E (5141) LEE: Read bytes [93] Acc [1581] Ret [0] Len[126]
E (5141) LEE: Read bytes [93] Acc [1674] Ret [0] Len[126]
E (5151) LEE: Read bytes [93] Acc [1767] Ret [0] Len[126]
E (5151) LEE: Read bytes [93] Acc [1860] Ret [0] Len[126]
E (5161) LEE: Read bytes [93] Acc [1953] Ret [0] Len[126]
E (5171) LEE: Read bytes [93] Acc [2046] Ret [0] Len[126]
E (5171) LEE: Read bytes [93] Acc [2139] Ret [0] Len[126]
E (5181) LEE: Read bytes [93] Acc [2232] Ret [0] Len[126]
E (5191) LEE: Read bytes [93] Acc [2325] Ret [0] Len[126]
E (5191) LEE: Read bytes [93] Acc [2418] Ret [0] Len[126]
E (5201) LEE: Read bytes [93] Acc [2511] Ret [0] Len[126]
E (5201) LEE: Read bytes [93] Acc [2604] Ret [0] Len[126]
E (5211) LEE: Read bytes [93] Acc [2697] Ret [0] Len[126]
E (5221) LEE: Read bytes [93] Acc [2790] Ret [0] Len[126]
E (5221) LEE: Read bytes [93] Acc [2883] Ret [0] Len[126]
E (5231) LEE: Read bytes [93] Acc [2976] Ret [0] Len[126]
E (5241) LEE: Read bytes [93] Acc [3069] Ret [0] Len[126]
E (5241) LEE: Read bytes [93] Acc [3162] Ret [0] Len[126]
E (5251) LEE: Read bytes [93] Acc [3255] Ret [0] Len[126]
E (5251) LEE: Read bytes [93] Acc [3348] Ret [0] Len[126]
E (5261) LEE: Read bytes [93] Acc [3441] Ret [0] Len[126]
E (5261) LEE: Read bytes [93] Acc [3534] Ret [0] Len[126]
E (5271) LEE: Read bytes [93] Acc [3627] Ret [0] Len[126]
E (5281) LEE: Read bytes [93] Acc [3720] Ret [0] Len[126]
E (5281) LEE: Read bytes [93] Acc [3813] Ret [0] Len[126]
E (5291) LEE: Read bytes [93] Acc [3906] Ret [0] Len[126]
E (5291) LEE: Read bytes [93] Acc [3999] Ret [0] Len[126]
E (5301) LEE: Read bytes [93] Acc [4092] Ret [0] Len[126]
E (5311) LEE: Read bytes [93] Acc [4185] Ret [0] Len[126]
E (5311) LEE: Read bytes [93] Acc [4278] Ret [0] Len[126]
E (5321) LEE: Read bytes [93] Acc [4371] Ret [0] Len[126]
E (5331) LEE: Read bytes [93] Acc [4464] Ret [0] Len[126]
E (5331) LEE: Read bytes [93] Acc [4557] Ret [0] Len[126]
E (5341) LEE: Read bytes [93] Acc [4650] Ret [0] Len[126]
E (5341) LEE: Read bytes [93] Acc [4743] Ret [0] Len[126]
E (5351) LEE: Read bytes [93] Acc [4836] Ret [0] Len[126]
E (5361) LEE: Read bytes [93] Acc [4929] Ret [0] Len[126]
E (5361) LEE: Read bytes [93] Acc [5022] Ret [0] Len[126]
E (5371) LEE: Read bytes [93] Acc [5115] Ret [0] Len[126]
E (5371) LEE: Read bytes [93] Acc [5208] Ret [0] Len[126]
E (5381) LEE: Read bytes [93] Acc [5301] Ret [0] Len[126]
E (5391) LEE: Read bytes [93] Acc [5394] Ret [0] Len[126]
E (5391) LEE: Read bytes [93] Acc [5487] Ret [0] Len[126]
E (5401) LEE: Read bytes [93] Acc [5580] Ret [0] Len[126]
E (5401) LEE: Read bytes [93] Acc [5673] Ret [0] Len[126]
E (5411) LEE: Read bytes [93] Acc [5766] Ret [0] Len[126]
E (5421) LEE: Read bytes [93] Acc [5859] Ret [0] Len[126]
E (5421) LEE: Read bytes [93] Acc [5952] Ret [0] Len[126]
E (5431) LEE: Read bytes [93] Acc [6045] Ret [0] Len[126]
E (5431) LEE: Read bytes [93] Acc [6138] Ret [0] Len[126]
E (5441) LEE: Read bytes [93] Acc [6231] Ret [0] Len[126]
E (5451) LEE: Read bytes [93] Acc [6324] Ret [0] Len[126]
E (5451) LEE: Read bytes [93] Acc [6417] Ret [0] Len[126]
E (5461) LEE: Read bytes [93] Acc [6510] Ret [0] Len[126]
E (5471) LEE: Read bytes [93] Acc [6603] Ret [0] Len[126]
E (5471) LEE: Read bytes [93] Acc [6696] Ret [0] Len[126]
E (5481) LEE: Read bytes [93] Acc [6789] Ret [0] Len[126]
E (5481) LEE: Read bytes [93] Acc [6882] Ret [0] Len[126]
E (5491) LEE: Read bytes [93] Acc [6975] Ret [0] Len[126]
E (5501) LEE: Read bytes [93] Acc [7068] Ret [0] Len[126]
E (5501) LEE: Read bytes [93] Acc [7161] Ret [0] Len[126]
E (5511) LEE: Read bytes [93] Acc [7254] Ret [0] Len[126]
E (5511) LEE: Read bytes [93] Acc [7347] Ret [0] Len[126]
E (5521) LEE: Read bytes [93] Acc [7440] Ret [0] Len[126]
E (5531) LEE: Read bytes [93] Acc [7533] Ret [0] Len[126]
E (5531) LEE: Read bytes [93] Acc [7626] Ret [0] Len[126]
E (5541) LEE: Read bytes [93] Acc [7719] Ret [0] Len[126]
E (5541) LEE: Read bytes [93] Acc [7812] Ret [0] Len[126]
E (5551) LEE: Read bytes [93] Acc [7905] Ret [0] Len[126]
E (5561) LEE: Read bytes [93] Acc [7998] Ret [0] Len[126]
E (5561) LEE: Read bytes [93] Acc [8091] Ret [0] Len[126]
E (5571) LEE: Read bytes [93] Acc [8184] Ret [0] Len[126]
E (5571) LEE: Read bytes [93] Acc [8277] Ret [0] Len[126]
E (5581) LEE: Read bytes [93] Acc [8370] Ret [0] Len[126]
E (5591) LEE: Read bytes [93] Acc [8463] Ret [0] Len[126]
E (5591) LEE: Read bytes [93] Acc [8556] Ret [0] Len[126]
E (5601) LEE: Read bytes [93] Acc [8649] Ret [0] Len[126]
E (5601) LEE: Read bytes [93] Acc [8742] Ret [0] Len[126]
E (5611) LEE: Read bytes [93] Acc [8835] Ret [0] Len[126]
E (5621) LEE: Read bytes [93] Acc [8928] Ret [0] Len[126]
E (5621) LEE: Read bytes [93] Acc [9021] Ret [0] Len[126]
E (5631) LEE: Read bytes [93] Acc [9114] Ret [0] Len[126]
E (5641) LEE: Read bytes [93] Acc [9207] Ret [0] Len[126]
E (5641) LEE: Read bytes [93] Acc [9300] Ret [0] Len[126]
E (5651) LEE: Read bytes [93] Acc [9393] Ret [0] Len[126]
E (5651) LEE: Read bytes [93] Acc [9486] Ret [0] Len[126]
E (5661) LEE: Read bytes [93] Acc [9579] Ret [0] Len[126]
E (5671) LEE: Read bytes [93] Acc [9672] Ret [0] Len[126]
E (5671) LEE: Read bytes [93] Acc [9765] Ret [0] Len[126]
E (5681) LEE: Read bytes [93] Acc [9858] Ret [0] Len[126]
E (5681) LEE: Read bytes [93] Acc [9951] Ret [0] Len[126]
E (5691) LEE: Read bytes [93] Acc [10044] Ret [0] Len[126]
E (5701) LEE: Read bytes [93] Acc [10137] Ret [0] Len[126]
E (5701) LEE: Read bytes [93] Acc [10230] Ret [0] Len[126]
E (5711) LEE: Read bytes [93] Acc [10323] Ret [0] Len[126]
E (5711) LEE: Read bytes [93] Acc [10416] Ret [0] Len[126]
E (5721) LEE: Read bytes [93] Acc [10509] Ret [0] Len[126]
E (5731) LEE: Read bytes [93] Acc [10602] Ret [0] Len[126]
E (5731) LEE: Read bytes [93] Acc [10695] Ret [0] Len[126]
E (5741) LEE: Read bytes [93] Acc [10788] Ret [0] Len[126]
E (5751) LEE: Read bytes [93] Acc [10881] Ret [0] Len[126]
E (5751) LEE: Read bytes [93] Acc [10974] Ret [0] Len[126]
E (5761) LEE: Read bytes [93] Acc [11067] Ret [0] Len[126]
E (5761) LEE: Read bytes [93] Acc [11160] Ret [0] Len[126]
E (5771) LEE: Read bytes [93] Acc [11253] Ret [0] Len[126]
E (5781) LEE: Read bytes [93] Acc [11346] Ret [0] Len[126]
E (5781) LEE: Read bytes [93] Acc [11439] Ret [0] Len[126]
E (5791) LEE: Read bytes [93] Acc [11532] Ret [0] Len[126]
E (5791) LEE: Read bytes [93] Acc [11625] Ret [0] Len[126]
E (5801) LEE: Read bytes [93] Acc [11718] Ret [0] Len[126]
E (5811) LEE: Read bytes [93] Acc [11811] Ret [0] Len[126]
E (5811) LEE: Read bytes [93] Acc [11904] Ret [0] Len[126]
E (5821) LEE: Read bytes [93] Acc [11997] Ret [0] Len[126]
E (5831) LEE: Read bytes [93] Acc [12090] Ret [0] Len[126]
E (5831) LEE: Read bytes [93] Acc [12183] Ret [0] Len[126]
E (5841) LEE: Read bytes [93] Acc [12276] Ret [0] Len[126]
E (5841) LEE: Read bytes [93] Acc [12369] Ret [0] Len[126]
E (5851) LEE: Read bytes [93] Acc [12462] Ret [0] Len[126]
E (5861) LEE: Read bytes [93] Acc [12555] Ret [0] Len[126]
E (5861) LEE: Read bytes [93] Acc [12648] Ret [0] Len[126]
E (5871) LEE: Read bytes [93] Acc [12741] Ret [0] Len[126]
E (5871) LEE: Read bytes [93] Acc [12834] Ret [0] Len[126]
E (5881) LEE: Read bytes [93] Acc [12927] Ret [0] Len[126]
E (5891) LEE: Read bytes [93] Acc [13020] Ret [0] Len[126]
E (5891) LEE: Read bytes [93] Acc [13113] Ret [0] Len[126]
E (5901) LEE: Read bytes [93] Acc [13206] Ret [0] Len[126]
E (5911) LEE: Read bytes [93] Acc [13299] Ret [0] Len[126]
E (5911) LEE: Read bytes [93] Acc [13392] Ret [0] Len[126]
E (5921) LEE: Read bytes [93] Acc [13485] Ret [0] Len[126]
E (5931) LEE: Read bytes [93] Acc [13578] Ret [0] Len[126]
E (5931) LEE: Read bytes [93] Acc [13671] Ret [0] Len[126]
E (5941) LEE: Read bytes [93] Acc [13764] Ret [0] Len[126]
E (5941) LEE: Read bytes [93] Acc [13857] Ret [0] Len[126]
E (5951) LEE: Read bytes [93] Acc [13950] Ret [0] Len[126]
E (5951) LEE: Read bytes [93] Acc [14043] Ret [0] Len[126]
E (5961) LEE: Read bytes [93] Acc [14136] Ret [0] Len[126]
E (5971) LEE: Read bytes [93] Acc [14229] Ret [0] Len[126]
E (5971) LEE: Read bytes [93] Acc [14322] Ret [0] Len[126]
E (5981) LEE: Read bytes [93] Acc [14415] Ret [0] Len[126]
E (5991) LEE: Read bytes [93] Acc [14508] Ret [0] Len[126]
E (5991) LEE: Read bytes [93] Acc [14601] Ret [0] Len[126]
E (6001) LEE: Read bytes [93] Acc [14694] Ret [0] Len[126]
E (6001) LEE: Read bytes [93] Acc [14787] Ret [0] Len[126]
E (6011) LEE: Read bytes [93] Acc [14880] Ret [0] Len[126]
E (6021) LEE: Read bytes [93] Acc [14973] Ret [0] Len[126]
E (6021) LEE: Read bytes [93] Acc [15066] Ret [0] Len[126]
E (6031) LEE: Read bytes [93] Acc [15159] Ret [0] Len[126]
E (6031) LEE: Read bytes [93] Acc [15252] Ret [0] Len[126]
E (6041) LEE: Read bytes [93] Acc [15345] Ret [0] Len[126]
E (6051) LEE: Read bytes [93] Acc [15438] Ret [0] Len[126]
E (6051) LEE: Read bytes [93] Acc [15531] Ret [0] Len[126]
E (6061) LEE: Read bytes [93] Acc [15624] Ret [0] Len[126]
E (6071) LEE: Read bytes [93] Acc [15717] Ret [0] Len[126]
E (6071) LEE: Read bytes [93] Acc [15810] Ret [0] Len[126]
E (6081) LEE: Read bytes [93] Acc [15903] Ret [0] Len[126]
E (6081) LEE: Read bytes [93] Acc [15996] Ret [0] Len[126]
E (6091) LEE: Read bytes [93] Acc [16089] Ret [0] Len[126]
E (6101) LEE: Read bytes [93] Acc [16182] Ret [0] Len[126]
E (6101) LEE: Read bytes [93] Acc [16275] Ret [0] Len[126]
E (6111) LEE: Read bytes [93] Acc [16368] Ret [0] Len[126]
E (6111) LEE: Read bytes [93] Acc [16461] Ret [0] Len[126]
E (6121) LEE: Read bytes [93] Acc [16554] Ret [0] Len[126]
E (6131) LEE: Read bytes [93] Acc [16647] Ret [0] Len[126]
E (6131) LEE: Read bytes [93] Acc [16740] Ret [0] Len[126]
E (6141) LEE: Read bytes [93] Acc [16833] Ret [0] Len[126]
E (6151) LEE: Read bytes [93] Acc [16926] Ret [0] Len[126]
E (6151) LEE: Read bytes [93] Acc [17019] Ret [0] Len[126]
E (6161) LEE: Read bytes [93] Acc [17112] Ret [0] Len[126]
E (6161) LEE: Read bytes [93] Acc [17205] Ret [0] Len[126]
E (6171) LEE: Read bytes [93] Acc [17298] Ret [0] Len[126]
E (6181) LEE: Read bytes [93] Acc [17391] Ret [0] Len[126]
E (6181) LEE: Read bytes [93] Acc [17484] Ret [0] Len[126]
E (6191) LEE: Read bytes [93] Acc [17577] Ret [0] Len[126]
E (6191) LEE: Read bytes [93] Acc [17670] Ret [0] Len[126]
E (6201) LEE: Read bytes [93] Acc [17763] Ret [0] Len[126]
E (6211) LEE: Read bytes [93] Acc [17856] Ret [0] Len[126]
E (6211) LEE: Read bytes [93] Acc [17949] Ret [0] Len[126]
E (6221) LEE: Read bytes [93] Acc [18042] Ret [0] Len[126]
E (6231) LEE: Read bytes [93] Acc [18135] Ret [0] Len[126]
E (6231) LEE: Read bytes [93] Acc [18228] Ret [0] Len[126]
E (6241) LEE: Read bytes [93] Acc [18321] Ret [0] Len[126]
E (6241) LEE: Read bytes [93] Acc [18414] Ret [0] Len[126]
E (6251) LEE: Read bytes [93] Acc [18507] Ret [0] Len[126]
E (6261) LEE: Read bytes [93] Acc [18600] Ret [0] Len[126]
E (6261) LEE: Read bytes [93] Acc [18693] Ret [0] Len[126]
E (6271) LEE: Read bytes [93] Acc [18786] Ret [0] Len[126]
E (6281) LEE: Read bytes [93] Acc [18879] Ret [0] Len[126]
E (6281) LEE: Read bytes [93] Acc [18972] Ret [0] Len[126]
E (6291) LEE: Read bytes [93] Acc [19065] Ret [0] Len[126]
E (6291) LEE: Read bytes [93] Acc [19158] Ret [0] Len[126]
E (6301) LEE: Read bytes [93] Acc [19251] Ret [0] Len[126]
E (6311) LEE: Read bytes [93] Acc [19344] Ret [0] Len[126]
E (6311) LEE: Read bytes [93] Acc [19437] Ret [0] Len[126]
E (6321) LEE: Read bytes [93] Acc [19530] Ret [0] Len[126]
E (6321) LEE: Read bytes [93] Acc [19623] Ret [0] Len[126]
E (6331) LEE: Read bytes [93] Acc [19716] Ret [0] Len[126]
E (6341) LEE: Read bytes [93] Acc [19809] Ret [0] Len[126]
E (6341) LEE: Read bytes [93] Acc [19902] Ret [0] Len[126]
E (6351) LEE: Read bytes [93] Acc [19995] Ret [0] Len[126]
E (6361) LEE: Read bytes [93] Acc [20088] Ret [0] Len[126]
E (6361) LEE: Read bytes [93] Acc [20181] Ret [0] Len[126]
E (6371) LEE: Read bytes [93] Acc [20274] Ret [0] Len[126]
E (6371) LEE: Read bytes [93] Acc [20367] Ret [0] Len[126]
E (6381) LEE: Read bytes [93] Acc [20460] Ret [0] Len[126]
E (6391) LEE: Read bytes [93] Acc [20553] Ret [0] Len[126]
E (6391) LEE: Read bytes [93] Acc [20646] Ret [0] Len[126]
E (6401) LEE: Read bytes [93] Acc [20739] Ret [0] Len[126]
E (6401) LEE: Read bytes [93] Acc [20832] Ret [0] Len[126]
E (6411) LEE: Read bytes [93] Acc [20925] Ret [0] Len[126]
E (6421) LEE: Read bytes [93] Acc [21018] Ret [0] Len[126]
E (6421) LEE: Read bytes [93] Acc [21111] Ret [0] Len[126]
E (6431) LEE: Read bytes [93] Acc [21204] Ret [0] Len[126]
E (6441) LEE: Read bytes [93] Acc [21297] Ret [0] Len[126]
E (6441) LEE: Read bytes [93] Acc [21390] Ret [0] Len[126]
E (6451) LEE: Read bytes [93] Acc [21483] Ret [0] Len[126]
E (6451) LEE: Read bytes [93] Acc [21576] Ret [0] Len[126]
E (6461) LEE: Read bytes [93] Acc [21669] Ret [0] Len[126]
E (6471) LEE: Read bytes [93] Acc [21762] Ret [0] Len[126]
E (6471) LEE: Read bytes [93] Acc [21855] Ret [0] Len[126]
E (6481) LEE: Read bytes [93] Acc [21948] Ret [0] Len[126]
E (6481) LEE: Read bytes [93] Acc [22041] Ret [0] Len[126]
E (6491) LEE: Read bytes [93] Acc [22134] Ret [0] Len[126]
E (6501) LEE: Read bytes [93] Acc [22227] Ret [0] Len[126]
E (6501) LEE: Read bytes [93] Acc [22320] Ret [0] Len[126]
E (6511) LEE: Read bytes [93] Acc [22413] Ret [0] Len[126]
E (6521) LEE: Read bytes [93] Acc [22506] Ret [0] Len[126]
E (6521) LEE: Read bytes [93] Acc [22599] Ret [0] Len[126]
E (6531) LEE: Read bytes [93] Acc [22692] Ret [0] Len[126]
E (6531) LEE: Read bytes [93] Acc [22785] Ret [0] Len[126]
E (6541) LEE: Read bytes [93] Acc [22878] Ret [0] Len[126]
E (6551) LEE: Read bytes [93] Acc [22971] Ret [0] Len[126]
E (6551) LEE: Read bytes [93] Acc [23064] Ret [0] Len[126]
E (6561) LEE: Read bytes [93] Acc [23157] Ret [0] Len[126]
E (6561) LEE: Read bytes [93] Acc [23250] Ret [0] Len[126]
E (6571) LEE: Read bytes [93] Acc [23343] Ret [0] Len[126]
E (6581) LEE: Read bytes [93] Acc [23436] Ret [0] Len[126]
E (6581) LEE: Read bytes [93] Acc [23529] Ret [0] Len[126]
E (6591) LEE: Read bytes [93] Acc [23622] Ret [0] Len[126]
E (6601) LEE: Read bytes [93] Acc [23715] Ret [0] Len[126]
E (6601) LEE: Read bytes [93] Acc [23808] Ret [0] Len[126]
E (6611) LEE: Read bytes [93] Acc [23901] Ret [0] Len[126]
E (6611) LEE: Read bytes [93] Acc [23994] Ret [0] Len[126]
E (6621) LEE: Read bytes [93] Acc [24087] Ret [0] Len[126]
E (6631) LEE: Read bytes [93] Acc [24180] Ret [0] Len[126]
E (6631) LEE: Read bytes [93] Acc [24273] Ret [0] Len[126]
E (6641) LEE: Read bytes [93] Acc [24366] Ret [0] Len[126]
E (6641) LEE: Read bytes [93] Acc [24459] Ret [0] Len[126]
E (6651) LEE: Read bytes [93] Acc [24552] Ret [0] Len[126]
E (6661) LEE: Read bytes [93] Acc [24645] Ret [0] Len[126]
E (6661) LEE: Read bytes [93] Acc [24738] Ret [0] Len[126]
E (6671) LEE: Read bytes [93] Acc [24831] Ret [0] Len[126]
E (6681) LEE: Read bytes [93] Acc [24924] Ret [0] Len[126]
E (6681) LEE: Read bytes [93] Acc [25017] Ret [0] Len[126]
E (6691) LEE: Read bytes [93] Acc [25110] Ret [0] Len[126]
E (6691) LEE: Read bytes [93] Acc [25203] Ret [0] Len[126]
E (6701) LEE: Read bytes [93] Acc [25296] Ret [0] Len[126]
E (6711) LEE: Read bytes [93] Acc [25389] Ret [0] Len[126]
E (6711) LEE: Read bytes [93] Acc [25482] Ret [0] Len[126]
E (6721) LEE: Read bytes [93] Acc [25575] Ret [0] Len[126]
E (6721) LEE: Read bytes [93] Acc [25668] Ret [0] Len[126]
E (6731) LEE: Read bytes [93] Acc [25761] Ret [0] Len[126]
E (6741) LEE: Read bytes [93] Acc [25854] Ret [0] Len[126]
E (6741) LEE: Read bytes [93] Acc [25947] Ret [0] Len[126]
E (6751) LEE: Read bytes [93] Acc [26040] Ret [0] Len[126]
E (6761) LEE: Read bytes [93] Acc [26133] Ret [0] Len[126]
E (6761) LEE: Read bytes [93] Acc [26226] Ret [0] Len[126]
E (6771) LEE: Read bytes [93] Acc [26319] Ret [0] Len[126]
E (6771) LEE: Read bytes [93] Acc [26412] Ret [0] Len[126]
E (6781) LEE: Read bytes [93] Acc [26505] Ret [0] Len[126]
E (6791) LEE: Read bytes [93] Acc [26598] Ret [0] Len[126]
E (6791) LEE: Read bytes [93] Acc [26691] Ret [0] Len[126]
E (6801) LEE: Read bytes [93] Acc [26784] Ret [0] Len[126]
E (6811) LEE: Read bytes [93] Acc [26877] Ret [0] Len[126]
E (6811) LEE: Read bytes [93] Acc [26970] Ret [0] Len[126]
E (6821) LEE: Read bytes [93] Acc [27063] Ret [0] Len[126]
E (6821) LEE: Read bytes [93] Acc [27156] Ret [0] Len[126]
E (6831) LEE: Read bytes [93] Acc [27249] Ret [0] Len[126]
E (6841) LEE: Read bytes [93] Acc [27342] Ret [0] Len[126]
E (6841) LEE: Read bytes [93] Acc [27435] Ret [0] Len[126]
E (6851) LEE: Read bytes [93] Acc [27528] Ret [0] Len[126]
E (6851) LEE: Read bytes [93] Acc [27621] Ret [0] Len[126]
E (6861) LEE: Read bytes [93] Acc [27714] Ret [0] Len[126]
E (6871) LEE: Read bytes [93] Acc [27807] Ret [0] Len[126]
E (6871) LEE: Read bytes [93] Acc [27900] Ret [0] Len[126]
E (6881) LEE: Read bytes [93] Acc [27993] Ret [0] Len[126]
E (6891) LEE: Read bytes [93] Acc [28086] Ret [0] Len[126]
E (6891) LEE: Read bytes [93] Acc [28179] Ret [0] Len[126]
E (6901) LEE: Read bytes [93] Acc [28272] Ret [0] Len[126]
E (6901) LEE: Read bytes [93] Acc [28365] Ret [0] Len[126]
E (6911) LEE: Read bytes [93] Acc [28458] Ret [0] Len[126]
E (6921) LEE: Read bytes [93] Acc [28551] Ret [0] Len[126]
E (6921) LEE: Read bytes [93] Acc [28644] Ret [0] Len[126]
E (6931) LEE: Read bytes [93] Acc [28737] Ret [0] Len[126]
E (6931) LEE: Read bytes [93] Acc [28830] Ret [0] Len[126]
E (6941) LEE: Read bytes [93] Acc [28923] Ret [0] Len[126]
E (6951) LEE: Read bytes [93] Acc [29016] Ret [0] Len[126]
E (6951) LEE: Read bytes [93] Acc [29109] Ret [0] Len[126]
E (6961) LEE: Read bytes [93] Acc [29202] Ret [0] Len[126]
E (6971) LEE: Read bytes [93] Acc [29295] Ret [0] Len[126]
E (6971) LEE: Read bytes [93] Acc [29388] Ret [0] Len[126]
E (6981) LEE: Read bytes [93] Acc [29481] Ret [0] Len[126]
E (6981) LEE: Read bytes [93] Acc [29574] Ret [0] Len[126]
E (6991) LEE: Read bytes [93] Acc [29667] Ret [0] Len[126]
E (7001) LEE: Read bytes [93] Acc [29760] Ret [0] Len[126]
E (7001) LEE: Read bytes [93] Acc [29853] Ret [0] Len[126]
E (7011) LEE: Read bytes [93] Acc [29946] Ret [0] Len[126]
E (7011) LEE: Read bytes [93] Acc [30039] Ret [0] Len[126]
E (7021) LEE: Read bytes [93] Acc [30132] Ret [0] Len[126]
E (7031) LEE: Read bytes [93] Acc [30225] Ret [0] Len[126]
E (7031) LEE: Read bytes [93] Acc [30318] Ret [0] Len[126]
E (7041) LEE: Read bytes [93] Acc [30411] Ret [0] Len[126]
E (7051) LEE: Read bytes [93] Acc [30504] Ret [0] Len[126]
E (7051) LEE: Read bytes [93] Acc [30597] Ret [0] Len[126]
E (7061) LEE: Read bytes [93] Acc [30690] Ret [0] Len[126]
E (7061) LEE: Read bytes [93] Acc [30783] Ret [0] Len[126]
E (7071) LEE: Read bytes [93] Acc [30876] Ret [0] Len[126]
E (7081) LEE: Read bytes [93] Acc [30969] Ret [0] Len[126]
E (7081) LEE: Read bytes [93] Acc [31062] Ret [0] Len[126]
E (7091) LEE: Read bytes [93] Acc [31155] Ret [0] Len[126]
E (7101) LEE: Read bytes [93] Acc [31248] Ret [0] Len[126]
E (7101) LEE: Read bytes [93] Acc [31341] Ret [0] Len[126]
E (7111) LEE: Read bytes [93] Acc [31434] Ret [0] Len[126]
E (7111) LEE: Read bytes [93] Acc [31527] Ret [0] Len[126]
E (7121) LEE: Read bytes [93] Acc [31620] Ret [0] Len[126]
E (7131) LEE: Read bytes [93] Acc [31713] Ret [0] Len[126]
E (7131) LEE: Read bytes [93] Acc [31806] Ret [0] Len[126]
E (7141) LEE: Read bytes [93] Acc [31899] Ret [0] Len[126]
E (7141) LEE: Read bytes [93] Acc [31992] Ret [0] Len[126]
E (7151) LEE: Read bytes [93] Acc [32085] Ret [0] Len[126]
E (7161) LEE: Read bytes [93] Acc [32178] Ret [0] Len[126]
E (7161) LEE: Read bytes [93] Acc [32271] Ret [0] Len[126]
E (7171) LEE: Read bytes [93] Acc [32364] Ret [0] Len[126]
E (7171) LEE: Read bytes [93] Acc [32457] Ret [0] Len[126]
E (7181) LEE: Read bytes [12] Acc [32469] Ret [0] Len[18]
E (7191) LEE: Ret [0] Len[15]
I (8121) smtp_example: Email sent!

nAcc accumulates the total read_bytes and it comes out at 32469 and my Linux machine has the actual file size as 32468.

Attached is the file received - I had to zip it because the forum here wouldn't let me upload a 0 length file saying it is "too large"!.

Hope this helps.

Thanks

Lee.
Attachments
sample_image.jpg.zip
(130 Bytes) Downloaded 468 times

ESP_Vikram
Posts: 24
Joined: Fri Nov 23, 2018 12:07 pm

Re: ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby ESP_Vikram » Tue Feb 04, 2020 12:07 pm

@leenowell thanks for letting know you figured out port number issue.

1. As far as, `image name` sent in email, it should not matter.
2. For setup of WiFi info, you need to set this info under `Example Connection Configuration` via menuconfig as suggested in README.md.
I think you already have figured this bit out!
3. Image sent is 1 byte larger...
There indeed was a bug in my code.
4. Sending multiple emails..
Thanks for reporting this.
Yes, this can very much be done. I have added the loop for understanding.

Attached here is fixed example.

For receiving part, I haven't really explored this! But we should need to do POP/IMAP protocol setup for that I suppose.

Inputs are welcome!
Attachments
smtp_client.zip
(45.34 KiB) Downloaded 525 times

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: ESP32 IDF smtp (Simple Mail Transfer Protocol) support

Postby leenowell » Tue Feb 04, 2020 10:11 pm

@Vikram

I have tested the revised code and the byte count now seems to work fine. Unfortunately, the attachment still comes through via email as 0 bytes. A couple of comments/ questions on your responses below :)

1. How do you specify which file to upload and how does it get to the ESP to then attach to the email? For another bit of my project I am getting the ESP to call a number on event and wanted to play a recorded voice but couldn't work out how to do it.
2. To make it a bit easier to incorporate your example into other projects, instead of using the example_connect() call, adding the individual calls would be easier to follow.
3. Thanks for adding the loop makes sense. As a suggestion, putting it into a separate function would help others to include into their project (e.g. in their project might be detect XYZ then send email). Also would show which variables need to be global as needed in the "connect to SMPT server" as well as the send_email function (could take, to/ from/ message etc. as parameters). Would also show how to deal with it outside/ together with the initialize task.

thanks again for sharing this and happy to test next update when you have it.

Who is online

Users browsing this forum: No registered users and 135 guests