Skip to content

Commit

Permalink
Fix the IMAP issue #94, unable to save file to SD media since v1.3.3 …
Browse files Browse the repository at this point in the history
…to v1.5.1.
  • Loading branch information
mobizt committed Sep 14, 2021
1 parent 097ac3e commit 29547aa
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mail Client Arduino Library v1.5.1
# Mail Client Arduino Library v1.5.2


[![Join the chat at https://gitter.im/mobizt/ESP_Mail_Client](https://badges.gitter.im/mobizt/ESP_Mail_Client.svg)](https://gitter.im/mobizt/ESP_Mail_Client?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand Down
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": "1.5.1",
"version": "1.5.2",
"keywords": "communication, email, imap, smtp, esp32, esp8266, samd, arduino",
"description": "E-Mail Client Arduino Library that supports Espressif ESP32, ESP8266 and SAMD21 devices with built-in U-blox NINA-W102 module. This allows embedded devices to send, read Email, and get mailbox changes notification. The various types of content and attacment are supported. The library also supports Ethernet connection (ESP8266 and ESP32) through secure (SSL) and non-secure ports.",
"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=1.5.1
version=1.5.2

author=Mobizt

Expand Down
37 changes: 18 additions & 19 deletions src/ESP_Mail_Client.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* Mail Client Arduino Library for Espressif's ESP32 and ESP8266 and SAMD21 with u-blox NINA-W102 WiFi/Bluetooth module
*
* Version: 1.5.1
* Version: 1.5.2
* Released: September 14, 2021
*
* Updates:
* - Fix the IMAP issue #94, undetected attachments and unable to download since v1.3.3 to v1.5.0.
* - Defer the IMAP polling error report.
* - Fix the IMAP issue #94, unable to save file to SD media since v1.3.3 to v1.5.1.
*
*
* 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 @@ -396,14 +395,14 @@ bool ESP_Mail_Client::readMail(IMAPSession *imap, bool closeSession)

if (imap->_config->download.text || imap->_config->download.html || imap->_config->download.attachment || imap->_config->download.inlineImg)
{
if (!_sdOk && imap->_storageType == esp_mail_file_storage_type_sd)
if (!_sdOk && imap->_config->storage.type == esp_mail_file_storage_type_sd)
{
_sdOk = sdTest();
if (_sdOk)
if (!ESP_MAIL_SD_FS.exists(imap->_config->storage.saved_path))
createDirs(imap->_config->storage.saved_path);
}
else if (!_flashOk && imap->_storageType == esp_mail_file_storage_type_flash)
else if (!_flashOk && imap->_config->storage.type == esp_mail_file_storage_type_flash)
#if defined(ESP32)
_flashOk = ESP_MAIL_FLASH_FS.begin(FORMAT_FLASH);
#elif defined(ESP8266)
Expand Down Expand Up @@ -595,15 +594,15 @@ bool ESP_Mail_Client::readMail(IMAPSession *imap, bool closeSession)

if (closeSession)
{
if (imap->_storageType == esp_mail_file_storage_type_sd)
if (imap->_config->storage.type == esp_mail_file_storage_type_sd)
{
#if defined(ESP_MAIL_SD_FS)
if (_sdOk)
ESP_MAIL_SD_FS.end();
#endif
_sdOk = false;
}
else if (imap->_storageType == esp_mail_file_storage_type_flash)
else if (imap->_config->storage.type == esp_mail_file_storage_type_flash)
{

#if defined(ESP_MAIL_FLASH_FS)
Expand Down Expand Up @@ -6051,9 +6050,9 @@ void ESP_Mail_Client::saveHeader(IMAPSession *imap)

std::string headerFilePath;
prepareFilePath(imap, headerFilePath, true);
if (imap->_storageType == esp_mail_file_storage_type_sd && !_sdOk)
if (imap->_config->storage.type == esp_mail_file_storage_type_sd && !_sdOk)
_sdOk = sdTest();
else if (imap->_storageType == esp_mail_file_storage_type_flash && !_flashOk)
else if (imap->_config->storage.type == esp_mail_file_storage_type_flash && !_flashOk)
#if defined(ESP32)
_flashOk = ESP_MAIL_FLASH_FS.begin(FORMAT_FLASH);
#elif defined(ESP8266)
Expand All @@ -6065,9 +6064,9 @@ void ESP_Mail_Client::saveHeader(IMAPSession *imap)
if (file)
file.close();

if (imap->_storageType == esp_mail_file_storage_type_sd)
if (imap->_config->storage.type == esp_mail_file_storage_type_sd)
file = ESP_MAIL_SD_FS.open(headerFilePath.c_str(), FILE_WRITE);
else if (imap->_storageType == esp_mail_file_storage_type_flash)
else if (imap->_config->storage.type == esp_mail_file_storage_type_flash)
#if defined(ESP32)
file = ESP_MAIL_FLASH_FS.open(headerFilePath.c_str(), FILE_WRITE);
#elif defined(ESP8266)
Expand Down Expand Up @@ -6289,9 +6288,9 @@ bool ESP_Mail_Client::handleAttachment(IMAPSession *imap, char *buf, int bufLen,

cPart(imap)->file_open_write = true;

if (imap->_storageType == esp_mail_file_storage_type_sd && !_sdOk)
if (imap->_config->storage.type == esp_mail_file_storage_type_sd && !_sdOk)
_sdOk = sdTest();
else if (imap->_storageType == esp_mail_file_storage_type_flash && !_flashOk)
else if (imap->_config->storage.type == esp_mail_file_storage_type_flash && !_flashOk)
#if defined(ESP32)
_flashOk = ESP_MAIL_FLASH_FS.begin(FORMAT_FLASH);
#elif defined(ESP8266)
Expand All @@ -6312,7 +6311,7 @@ bool ESP_Mail_Client::handleAttachment(IMAPSession *imap, char *buf, int bufLen,
delS(tmp);

#if defined(ESP_MAIL_SD_FS)
if (imap->_storageType == esp_mail_file_storage_type_sd)
if (imap->_config->storage.type == esp_mail_file_storage_type_sd)
if (!ESP_MAIL_SD_FS.exists(filePath.c_str()))
createDirs(filePath);
#endif
Expand All @@ -6321,11 +6320,11 @@ bool ESP_Mail_Client::handleAttachment(IMAPSession *imap, char *buf, int bufLen,

filePath += cPart(imap)->filename;

if (imap->_storageType == esp_mail_file_storage_type_sd)
if (imap->_config->storage.type == esp_mail_file_storage_type_sd)
#if defined(ESP_MAIL_SD_FS)
file = ESP_MAIL_SD_FS.open(filePath.c_str(), FILE_WRITE);
#endif
else if (imap->_storageType == esp_mail_file_storage_type_flash)
else if (imap->_config->storage.type == esp_mail_file_storage_type_flash)
{
#if defined(ESP_MAIL_FLASH_FS)
#if defined(ESP32)
Expand Down Expand Up @@ -6727,13 +6726,13 @@ void ESP_Mail_Client::decodeText(IMAPSession *imap, char *buf, int bufLen, int &
{
downloadRequest = true;

if (imap->_storageType == esp_mail_file_storage_type_sd)
if (imap->_config->storage.type == esp_mail_file_storage_type_sd)
{
#if defined(ESP_MAIL_SD_FS)
file = ESP_MAIL_SD_FS.open(filePath.c_str(), FILE_WRITE);
#endif
}
else if (imap->_storageType == esp_mail_file_storage_type_flash)
else if (imap->_config->storage.type == esp_mail_file_storage_type_flash)
{
#if defined(ESP_MAIL_FLASH_FS)
#if defined(ESP32)
Expand Down Expand Up @@ -6765,7 +6764,7 @@ void ESP_Mail_Client::prepareFilePath(IMAPSession *imap, std::string &filePath,
fpath += tmp;
delS(tmp);

if (imap->_storageType == esp_mail_file_storage_type_sd)
if (imap->_config->storage.type == esp_mail_file_storage_type_sd)
if (!ESP_MAIL_SD_FS.exists(fpath.c_str()))
createDirs(fpath);

Expand Down
8 changes: 3 additions & 5 deletions src/ESP_Mail_Client.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#ifndef ESP_Mail_Client_H
#define ESP_Mail_Client_H

#define ESP_MAIL_VERSION "1.5.1"
#define ESP_MAIL_VERSION "1.5.2"

/**
* Mail Client Arduino Library for Espressif's ESP32 and ESP8266 and SAMD21 with u-blox NINA-W102 WiFi/Bluetooth module
*
* Version: 1.5.1
* Version: 1.5.2
* Released: September 14, 2021
*
* Updates:
* - Fix the IMAP issue #94, undetected attachments and unable to download since v1.3.3 to v1.5.0.
* - Defer the IMAP polling error report.
* - Fix the IMAP issue #94, unable to save file to SD media since v1.3.3 to v1.5.1.
*
*
* 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 @@ -2687,7 +2686,6 @@ class IMAPSession
esp_mail_imap_command _imap_cmd = esp_mail_imap_command::esp_mail_imap_cmd_login;
std::vector<struct esp_mail_imap_multipart_level_t> _multipart_levels = std::vector<struct esp_mail_imap_multipart_level_t>();
int _rfc822_part_count = 0;
esp_mail_file_storage_type _storageType = esp_mail_file_storage_type::esp_mail_file_storage_type_flash;
bool _unseen = false;
bool _readOnlyMode = true;
struct esp_mail_auth_capability_t _auth_capability;
Expand Down
1 change: 0 additions & 1 deletion src/ESP_Mail_FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#define CARD_TYPE_SD_MMC 1
*
*/

#define ESP_Mail_DEFAULT_SD_FS SD
#define CARD_TYPE_SD 1

Expand Down

0 comments on commit 29547aa

Please sign in to comment.