Skip to content

Commit

Permalink
Fix SMTP multipart message issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Oct 20, 2022
1 parent b49ddea commit fa7ac9d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ESP Mail Client",
"version": "2.5.3",
"version": "2.6.0",
"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": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=ESP Mail Client

version=2.5.3
version=2.6.0

author=Mobizt

Expand Down
2 changes: 1 addition & 1 deletion src/ESP_Mail_Client_Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

#ifndef ESP_MAIL_VERSION

#define ESP_MAIL_VERSION "2.5.3"
#define ESP_MAIL_VERSION "2.6.0"

#endif
23 changes: 10 additions & 13 deletions src/ESP_Mail_SMTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Mail Client Arduino Library for Espressif's ESP32 and ESP8266 and SAMD21 with u-blox NINA-W102 WiFi/Bluetooth module
*
* Created October 1, 2022
* Created October 20, 2022
*
* This library allows Espressif's ESP32, ESP8266 and SAMD devices to send and read Email through the SMTP and IMAP servers.
*
Expand Down Expand Up @@ -2754,13 +2754,12 @@ bool ESP_Mail_Client::altSendData(uint8_t *data, size_t size, SMTPSession *smtp,

bool ESP_Mail_Client::sendMSG(SMTPSession *smtp, SMTP_Message *msg, const MB_String &boundary)
{
MB_String alt = getMIMEBoundary(15);
MB_String s;

if (numAtt(smtp, esp_mail_att_type_inline, msg) > 0)
{
s += esp_mail_str_297;
s += alt;
s += boundary;
s += esp_mail_str_35;

if (!sendBDAT(smtp, msg, s.length(), false))
Expand All @@ -2771,19 +2770,19 @@ bool ESP_Mail_Client::sendMSG(SMTPSession *smtp, SMTP_Message *msg, const MB_Str

if (msg->type == esp_mail_msg_type_plain || msg->type == esp_mail_msg_type_enriched || msg->type == esp_mail_msg_type_html)
{
if (!sendInline(smtp, msg, alt, msg->type))
if (!sendInline(smtp, msg, boundary, msg->type))
return false;
}
else if (msg->type == (esp_mail_msg_type_html | esp_mail_msg_type_enriched | esp_mail_msg_type_plain))
{
if (!sendPartText(smtp, msg, esp_mail_msg_type_plain, alt.c_str()))
if (!sendPartText(smtp, msg, esp_mail_msg_type_plain, boundary.c_str()))
return false;
if (!sendInline(smtp, msg, alt, esp_mail_msg_type_html))
if (!sendInline(smtp, msg, boundary, esp_mail_msg_type_html))
return false;
}

s = esp_mail_str_33;
s += alt;
s += boundary;
s += esp_mail_str_33;
s += esp_mail_str_34;

Expand All @@ -2802,11 +2801,9 @@ bool ESP_Mail_Client::sendMSG(SMTPSession *smtp, SMTP_Message *msg, const MB_Str
}
else if (msg->type == (esp_mail_msg_type_html | esp_mail_msg_type_enriched | esp_mail_msg_type_plain))
{
s = esp_mail_str_33;
s += boundary;
s += esp_mail_str_34;

s += esp_mail_str_297;
s += alt;
s += boundary;
s += esp_mail_str_35;

if (!sendBDAT(smtp, msg, s.length(), false))
Expand All @@ -2815,10 +2812,10 @@ bool ESP_Mail_Client::sendMSG(SMTPSession *smtp, SMTP_Message *msg, const MB_Str
if (!altSendData(s, false, smtp, msg, false, false, esp_mail_smtp_cmd_undefined, esp_mail_smtp_status_code_0, SMTP_STATUS_UNDEFINED))
return false;

if (!sendPartText(smtp, msg, esp_mail_msg_type_plain, alt.c_str()))
if (!sendPartText(smtp, msg, esp_mail_msg_type_plain, boundary.c_str()))
return false;

if (!sendPartText(smtp, msg, esp_mail_msg_type_html, alt.c_str()))
if (!sendPartText(smtp, msg, esp_mail_msg_type_html, boundary.c_str()))
return false;
}
}
Expand Down

0 comments on commit fa7ac9d

Please sign in to comment.