From d72154627752e542b039358c6e7bedc67160ab2c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 20 Jul 2024 09:15:27 +0700 Subject: [PATCH] Fix SMTP message address-list issue #348. --- library.json | 2 +- library.properties | 2 +- src/ESP_Mail_Client.h | 2 +- src/ESP_Mail_Client_Version.h | 4 ++-- src/ESP_Mail_SMTP.h | 15 ++++++++++----- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/library.json b/library.json index e09f34c..e0486e3 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ESP Mail Client", - "version": "3.4.20", + "version": "3.4.21", "keywords": "communication, email, imap, smtp, esp32, esp8266, samd, arduino", "description": "Arduino E-Mail Client Library to send, read and get incoming email notification for ESP32, ESP8266 and SAMD21 devices. The library also supported other Arduino Devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.", "repository": { diff --git a/library.properties b/library.properties index 007b262..378ab2a 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=ESP Mail Client -version=3.4.20 +version=3.4.21 author=Mobizt diff --git a/src/ESP_Mail_Client.h b/src/ESP_Mail_Client.h index 41cc34a..df06a33 100644 --- a/src/ESP_Mail_Client.h +++ b/src/ESP_Mail_Client.h @@ -5,7 +5,7 @@ /** * Mail Client Arduino Library for Arduino devices. * - * Created July 15, 2024 + * Created July 19, 2024 * * This library allows Espressif's ESP32, ESP8266, SAMD and RP2040 Pico devices to send and read Email through the SMTP and IMAP servers. * diff --git a/src/ESP_Mail_Client_Version.h b/src/ESP_Mail_Client_Version.h index dc2c27a..8cc53ef 100644 --- a/src/ESP_Mail_Client_Version.h +++ b/src/ESP_Mail_Client_Version.h @@ -3,8 +3,8 @@ #ifndef ESP_MAIL_VERSION -#define ESP_MAIL_VERSION "3.4.20" -#define ESP_MAIL_VERSION_NUM 30420 +#define ESP_MAIL_VERSION "3.4.21" +#define ESP_MAIL_VERSION_NUM 30421 /* The inconsistent file version checking to prevent mixed versions compilation. */ //#define VALID_VERSION_CHECK(ver) (ver == ESP_MAIL_VERSION_NUM) diff --git a/src/ESP_Mail_SMTP.h b/src/ESP_Mail_SMTP.h index 79c5d88..0fecc21 100644 --- a/src/ESP_Mail_SMTP.h +++ b/src/ESP_Mail_SMTP.h @@ -5,7 +5,7 @@ /** * Mail Client Arduino Library for Espressif's ESP32 and ESP8266, Raspberry Pi RP2040 Pico, and SAMD21 with u-blox NINA-W102 WiFi/Bluetooth module * - * Created August 28, 2023 + * Created July 19, 2024 * * This library allows Espressif's ESP32, ESP8266, SAMD and RP2040 Pico devices to send and read Email through the SMTP and IMAP servers. * @@ -318,7 +318,8 @@ bool ESP_Mail_Client::addSendingResult(SMTPSession *smtp, SMTP_Message *msg, boo if (msg->timestamp.tag.length() && msg->timestamp.format.length()) status.subject.replaceAll(msg->timestamp.tag, Time.getDateTimeString(Time.getCurrentTimestamp(), msg->timestamp.format.c_str())); - status.recipients = msg->_rcp[0].email.c_str(); + if (msg->_rcp.size()) + status.recipients = msg->_rcp[0].email.c_str(); smtp->sendingResult.add(&status); smtp->_cbData._sentSuccess = smtp->_sentSuccessCount; @@ -346,8 +347,11 @@ bool ESP_Mail_Client::addSendingResult(SMTPSession *smtp, SMTP_Message *msg, boo sendCallback(smtp, buf, false, false); snprintf(buf, bufLen, pgm2Str(esp_mail_str_96 /* "Date/Time: %s" */), Time.getDateTimeString(ts, "%B %d, %Y %H:%M:%S").c_str()); sendCallback(smtp, buf, false, false); - snprintf(buf, bufLen, pgm2Str(esp_mail_str_97 /* "Recipient: %s" */), msg->_rcp[0].email.c_str()); - sendCallback(smtp, buf, false, false); + if (msg->_rcp.size()) + { + snprintf(buf, bufLen, pgm2Str(esp_mail_str_97 /* "Recipient: %s" */), msg->_rcp[0].email.c_str()); + sendCallback(smtp, buf, false, false); + } snprintf(buf, bufLen, pgm2Str(esp_mail_str_92 /* "Subject: %s" */), msg->subject.c_str()); sendCallback(smtp, buf, false, false); freeMem(&buf); @@ -372,7 +376,8 @@ void ESP_Mail_Client::saveSendingLogs(SMTPSession *smtp, SMTP_Message *msg, bool mbfs->print(mbfs_type smtp->_session_cfg->sentLogs.storage_type, cm.c_str()); mbfs->print(mbfs_type smtp->_session_cfg->sentLogs.storage_type, (int)smtp->ts); mbfs->print(mbfs_type smtp->_session_cfg->sentLogs.storage_type, cm.c_str()); - mbfs->print(mbfs_type smtp->_session_cfg->sentLogs.storage_type, msg->_rcp[0].email.c_str()); + if (msg->_rcp.size()) + mbfs->print(mbfs_type smtp->_session_cfg->sentLogs.storage_type, msg->_rcp[0].email.c_str()); mbfs->print(mbfs_type smtp->_session_cfg->sentLogs.storage_type, cm.c_str()); mbfs->println(mbfs_type smtp->_session_cfg->sentLogs.storage_type, msg->subject.c_str()); mbfs->close(mbfs_type smtp->_session_cfg->sentLogs.storage_type);