mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-21 09:46:31 +00:00
fixes from GEMU2015
This commit is contained in:
parent
96ce74bdd8
commit
dba5cf2902
@ -2746,20 +2746,16 @@ bool ESP_Mail_Client::sendAttachments(SMTPSession *smtp, SMTP_Message *msg, cons
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if (att->file.storage_type == esp_mail_file_storage_type_univ) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (!_sdOk && att->file.storage_type == esp_mail_file_storage_type_sd)
|
if (!_sdOk && att->file.storage_type == esp_mail_file_storage_type_sd)
|
||||||
_sdOk = sdTest();
|
_sdOk = sdTest();
|
||||||
|
|
||||||
if (!_flashOk && att->file.storage_type == esp_mail_file_storage_type_flash) {
|
if (!_flashOk && att->file.storage_type == esp_mail_file_storage_type_flash)
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
//_flashOk = ESP_MAIL_FLASH_FS.begin(FORMAT_FLASH);
|
_flashOk = ESP_MAIL_FLASH_FS.begin(FORMAT_FLASH);
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
//_flashOk = ESP_MAIL_FLASH_FS.begin();
|
_flashOk = ESP_MAIL_FLASH_FS.begin();
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
if ((!_sdOk && att->file.storage_type == esp_mail_file_storage_type_sd) || (!_flashOk && att->file.storage_type == esp_mail_file_storage_type_flash))
|
if ((!_sdOk && att->file.storage_type == esp_mail_file_storage_type_sd) || (!_flashOk && att->file.storage_type == esp_mail_file_storage_type_flash))
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -2812,13 +2808,12 @@ bool ESP_Mail_Client::openFileRead(SMTPSession *smtp, SMTP_Message *msg, SMTP_At
|
|||||||
|
|
||||||
if (att->file.storage_type == esp_mail_file_storage_type_sd) {
|
if (att->file.storage_type == esp_mail_file_storage_type_sd) {
|
||||||
file_existed = ESP_MAIL_SD_FS.exists(filepath.c_str());
|
file_existed = ESP_MAIL_SD_FS.exists(filepath.c_str());
|
||||||
}
|
} else if (att->file.storage_type == esp_mail_file_storage_type_flash) {
|
||||||
else if (att->file.storage_type == esp_mail_file_storage_type_flash) {
|
|
||||||
}
|
|
||||||
else if (att->file.storage_type == esp_mail_file_storage_type_univ) {
|
|
||||||
file_existed = ESP_MAIL_FLASH_FS.exists(filepath.c_str());
|
file_existed = ESP_MAIL_FLASH_FS.exists(filepath.c_str());
|
||||||
|
} else if (att->file.storage_type == esp_mail_file_storage_type_univ) {
|
||||||
|
file_existed = ufsp->exists(filepath.c_str());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!file_existed)
|
if (!file_existed)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -2832,11 +2827,10 @@ bool ESP_Mail_Client::openFileRead(SMTPSession *smtp, SMTP_Message *msg, SMTP_At
|
|||||||
|
|
||||||
if (att->file.storage_type == esp_mail_file_storage_type_sd) {
|
if (att->file.storage_type == esp_mail_file_storage_type_sd) {
|
||||||
file_existed = ESP_MAIL_SD_FS.exists(filepath.c_str());
|
file_existed = ESP_MAIL_SD_FS.exists(filepath.c_str());
|
||||||
}
|
} else if (att->file.storage_type == esp_mail_file_storage_type_flash) {
|
||||||
else if (att->file.storage_type == esp_mail_file_storage_type_flash) {
|
|
||||||
}
|
|
||||||
else if (att->file.storage_type == esp_mail_file_storage_type_univ) {
|
|
||||||
file_existed = ESP_MAIL_FLASH_FS.exists(filepath.c_str());
|
file_existed = ESP_MAIL_FLASH_FS.exists(filepath.c_str());
|
||||||
|
} else if (att->file.storage_type == esp_mail_file_storage_type_univ) {
|
||||||
|
file_existed = ufsp->exists(filepath.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2861,17 +2855,16 @@ bool ESP_Mail_Client::openFileRead(SMTPSession *smtp, SMTP_Message *msg, SMTP_At
|
|||||||
|
|
||||||
if (att->file.storage_type == esp_mail_file_storage_type_sd) {
|
if (att->file.storage_type == esp_mail_file_storage_type_sd) {
|
||||||
file = ESP_MAIL_SD_FS.open(filepath.c_str(), FILE_READ);
|
file = ESP_MAIL_SD_FS.open(filepath.c_str(), FILE_READ);
|
||||||
}
|
} else if (att->file.storage_type == esp_mail_file_storage_type_flash) {
|
||||||
else if (att->file.storage_type == esp_mail_file_storage_type_flash) {
|
|
||||||
}
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
//file = ESP_MAIL_FLASH_FS.open(filepath.c_str(), FILE_READ);
|
file = ESP_MAIL_FLASH_FS.open(filepath.c_str(), FILE_READ);
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
//file = ESP_MAIL_FLASH_FS.open(filepath.c_str(), "r");
|
file = ESP_MAIL_FLASH_FS.open(filepath.c_str(), "r");
|
||||||
#endif
|
#endif
|
||||||
else if (att->file.storage_type == esp_mail_file_storage_type_univ) {
|
} else if (att->file.storage_type == esp_mail_file_storage_type_univ) {
|
||||||
file = ufsp->open(filepath.c_str(), "r");
|
file = ufsp->open(filepath.c_str(), "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -2904,10 +2897,13 @@ bool ESP_Mail_Client::openFileRead2(SMTPSession *smtp, SMTP_Message *msg, File &
|
|||||||
filepath += path;
|
filepath += path;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storageType == esp_mail_file_storage_type_sd)
|
if (storageType == esp_mail_file_storage_type_sd) {
|
||||||
file_existed = ESP_MAIL_SD_FS.exists(filepath.c_str());
|
file_existed = ESP_MAIL_SD_FS.exists(filepath.c_str());
|
||||||
else if (storageType == esp_mail_file_storage_type_flash)
|
} else if (storageType == esp_mail_file_storage_type_flash) {
|
||||||
file_existed = ESP_MAIL_FLASH_FS.exists(filepath.c_str());
|
file_existed = ESP_MAIL_FLASH_FS.exists(filepath.c_str());
|
||||||
|
} else if (storageType == esp_mail_file_storage_type_univ) {
|
||||||
|
file_existed = ufsp->exists(filepath.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if (!file_existed)
|
if (!file_existed)
|
||||||
{
|
{
|
||||||
@ -3034,18 +3030,16 @@ bool ESP_Mail_Client::sendInline(SMTPSession *smtp, SMTP_Message *msg, const std
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (att->file.storage_type == esp_mail_file_storage_type_univ) {
|
|
||||||
} else {
|
|
||||||
if (!_sdOk && att->file.storage_type == esp_mail_file_storage_type_sd)
|
if (!_sdOk && att->file.storage_type == esp_mail_file_storage_type_sd)
|
||||||
_sdOk = sdTest();
|
_sdOk = sdTest();
|
||||||
|
|
||||||
if (!_flashOk && att->file.storage_type == esp_mail_file_storage_type_flash) {
|
if (!_flashOk && att->file.storage_type == esp_mail_file_storage_type_flash)
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
//_flashOk = ESP_MAIL_FLASH_FS.begin(FORMAT_FLASH);
|
_flashOk = ESP_MAIL_FLASH_FS.begin(FORMAT_FLASH);
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
//_flashOk = ESP_MAIL_FLASH_FS.begin();
|
_flashOk = ESP_MAIL_FLASH_FS.begin();
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
if ((!_sdOk && att->file.storage_type == esp_mail_file_storage_type_sd) || (!_flashOk && att->file.storage_type == esp_mail_file_storage_type_flash))
|
if ((!_sdOk && att->file.storage_type == esp_mail_file_storage_type_sd) || (!_flashOk && att->file.storage_type == esp_mail_file_storage_type_flash))
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -6072,14 +6066,17 @@ void ESP_Mail_Client::saveHeader(IMAPSession *imap)
|
|||||||
if (file)
|
if (file)
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
if (imap->_storageType == esp_mail_file_storage_type_sd)
|
if (imap->_storageType == esp_mail_file_storage_type_sd) {
|
||||||
file = ESP_MAIL_SD_FS.open(headerFilePath.c_str(), FILE_WRITE);
|
file = ESP_MAIL_SD_FS.open(headerFilePath.c_str(), FILE_WRITE);
|
||||||
else if (imap->_storageType == esp_mail_file_storage_type_flash)
|
} else if (imap->_storageType == esp_mail_file_storage_type_flash) {
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
file = ESP_MAIL_FLASH_FS.open(headerFilePath.c_str(), FILE_WRITE);
|
file = ESP_MAIL_FLASH_FS.open(headerFilePath.c_str(), FILE_WRITE);
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
file = ESP_MAIL_FLASH_FS.open(headerFilePath.c_str(), "w");
|
file = ESP_MAIL_FLASH_FS.open(headerFilePath.c_str(), "w");
|
||||||
#endif
|
#endif
|
||||||
|
} else if (imap->_storageType == esp_mail_file_storage_type_univ) {
|
||||||
|
file = ufsp->open(headerFilePath.c_str(), "w");
|
||||||
|
}
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
|
@ -2789,10 +2789,18 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//#define EMAIL_DEBUG_PRINTLN Serial.println
|
||||||
|
//#define EMAIL_DEBUG_PRINT Serial.print
|
||||||
|
#define EMAIL_DEBUG_PRINTLN Tasmota_print
|
||||||
|
#define EMAIL_DEBUG_PRINT Tasmota_print
|
||||||
|
|
||||||
|
extern void Tasmota_print(const char *);
|
||||||
|
|
||||||
static void __attribute__((used)) esp_mail_debug(const char *msg)
|
static void __attribute__((used)) esp_mail_debug(const char *msg)
|
||||||
{
|
{
|
||||||
delay(0);
|
delay(0);
|
||||||
Serial.println(msg);
|
EMAIL_DEBUG_PRINTLN(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((used))
|
static void __attribute__((used))
|
||||||
@ -2800,11 +2808,13 @@ esp_mail_debug_line(const char *msg, bool newline)
|
|||||||
{
|
{
|
||||||
delay(0);
|
delay(0);
|
||||||
if (newline)
|
if (newline)
|
||||||
Serial.println(msg);
|
EMAIL_DEBUG_PRINTLN(msg);
|
||||||
else
|
else
|
||||||
Serial.print(msg);
|
EMAIL_DEBUG_PRINT(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern ESP_Mail_Client MailClient;
|
extern ESP_Mail_Client MailClient;
|
||||||
|
|
||||||
|
extern FS *ufsp;
|
||||||
|
|
||||||
#endif // ESP_Mail_Client_H
|
#endif // ESP_Mail_Client_H
|
||||||
|
@ -3,19 +3,11 @@
|
|||||||
#include <ESP_Mail_Client.h>
|
#include <ESP_Mail_Client.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef ESP8266
|
|
||||||
#ifndef SEND_MAIL32_MINRAM
|
#ifndef SEND_MAIL32_MINRAM
|
||||||
#undef SEND_MAIL32_MINRAM
|
#undef SEND_MAIL32_MINRAM
|
||||||
#define SEND_MAIL32_MINRAM 13*1024
|
#define SEND_MAIL32_MINRAM 70*1024
|
||||||
#endif
|
#endif
|
||||||
#endif // ESP8266
|
|
||||||
|
|
||||||
#ifdef ESP32
|
|
||||||
#ifndef SEND_MAIL32_MINRAM
|
|
||||||
#undef SEND_MAIL32_MINRAM
|
|
||||||
#define SEND_MAIL32_MINRAM 30*1024
|
|
||||||
#endif
|
|
||||||
#endif // ESP32
|
|
||||||
|
|
||||||
#define xPSTR(a) a
|
#define xPSTR(a) a
|
||||||
#define MAX_ATTCHMENTS 8
|
#define MAX_ATTCHMENTS 8
|
||||||
@ -41,7 +33,7 @@ uint16_t SendMail(char *buffer) {
|
|||||||
const char *to;
|
const char *to;
|
||||||
const char *subject;
|
const char *subject;
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
uint16_t status = 0;
|
uint16_t status = 1;
|
||||||
uint16_t blen;
|
uint16_t blen;
|
||||||
char *endcmd;
|
char *endcmd;
|
||||||
ESP_Mail_Session session;
|
ESP_Mail_Session session;
|
||||||
@ -173,8 +165,12 @@ uint16_t SendMail(char *buffer) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//smtp->debug(true);
|
#ifdef DEBUG_EMAIL_PORT
|
||||||
|
smtp->debug(true);
|
||||||
|
#else
|
||||||
smtp->debug(false);
|
smtp->debug(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
// smtp->callback(smtpCallback);
|
// smtp->callback(smtpCallback);
|
||||||
|
|
||||||
message.clearRecipients();
|
message.clearRecipients();
|
||||||
@ -219,14 +215,17 @@ uint16_t SendMail(char *buffer) {
|
|||||||
|
|
||||||
/* Connect to server with the session config */
|
/* Connect to server with the session config */
|
||||||
delay(0);
|
delay(0);
|
||||||
if (!smtp->connect(&session))
|
if (!smtp->connect(&session)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* Start sending the Email and close the session */
|
/* Start sending the Email and close the session */
|
||||||
delay(0);
|
delay(0);
|
||||||
|
|
||||||
if (!MailClient.sendMail(smtp, &message, true)) {
|
if (!MailClient.sendMail(smtp, &message, true)) {
|
||||||
Serial.println("Error sending Email, " + smtp->errorReason());
|
Serial.println("Error sending Email, " + smtp->errorReason());
|
||||||
|
} else {
|
||||||
|
status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -372,4 +371,16 @@ if (status.success())
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Tasmota_print(const char *txt) {
|
||||||
|
#ifdef DEBUG_EMAIL_PORT
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("ESP32mail: %s"),txt);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // USE_ESP32MAIL
|
#endif // USE_ESP32MAIL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user