From a5d3974c5684896fb7450eac577ca26614857ca5 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sun, 12 Apr 2020 19:28:19 +0200 Subject: [PATCH] sendmail ESP32 --- tasmota/WiFiClientSecureLightBearSSL.cpp | 2 +- tasmota/sendemail.h | 9 +++++++++ tasmota/sendemail.ino | 9 +++++++-- tasmota/xdrv_10_scripter.ino | 6 ++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tasmota/WiFiClientSecureLightBearSSL.cpp b/tasmota/WiFiClientSecureLightBearSSL.cpp index 20992a9dd..434522b14 100644 --- a/tasmota/WiFiClientSecureLightBearSSL.cpp +++ b/tasmota/WiFiClientSecureLightBearSSL.cpp @@ -22,7 +22,7 @@ #include "my_user_config.h" //#ifdef USE_MQTT_TLS -#if defined(USE_MQTT_TLS) || defined (USE_SENDMAIL) +#if defined ESP8266 && (defined(USE_MQTT_TLS) || defined (USE_SENDMAIL)) //#define DEBUG_TLS diff --git a/tasmota/sendemail.h b/tasmota/sendemail.h index 2422ad91f..f5a9334ea 100644 --- a/tasmota/sendemail.h +++ b/tasmota/sendemail.h @@ -8,7 +8,11 @@ #include //#include +#ifdef ESP8266 #include "WiFiClientSecureLightBearSSL.h" +#else +#include +#endif class SendEmail { @@ -20,12 +24,17 @@ class SendEmail const int timeout; const bool ssl; const int auth_used; +#ifdef ESP8266 #if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) WiFiClient* client; #else // use bear ssl BearSSL::WiFiClientSecure_light *client; #endif +#else + WiFiClient *client; +#endif + String readClient(); void a3_to_a4(unsigned char * a4, unsigned char * a3); int base64_encode(char *output, const char *input, int inputLen); diff --git a/tasmota/sendemail.ino b/tasmota/sendemail.ino index 70571b5d2..8bcddb029 100644 --- a/tasmota/sendemail.ino +++ b/tasmota/sendemail.ino @@ -174,12 +174,17 @@ exit: return status; } +#ifdef ESP8266 void script_send_email_body(BearSSL::WiFiClientSecure_light *client); - - SendEmail::SendEmail(const String& host, const int port, const String& user, const String& passwd, const int timeout, const int auth_used) : host(host), port(port), user(user), passwd(passwd), timeout(timeout), ssl(ssl), auth_used(auth_used), client(new BearSSL::WiFiClientSecure_light(1024,1024)) { } +#else +void script_send_email_body(WiFiClient *client); +SendEmail::SendEmail(const String& host, const int port, const String& user, const String& passwd, const int timeout, const int auth_used) : + host(host), port(port), user(user), passwd(passwd), timeout(timeout), ssl(ssl), auth_used(auth_used), client(new WiFiClientSecure()) { +} +#endif String SendEmail::readClient() { delay(0); diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index a5f5265b8..e086adedb 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -4720,7 +4720,13 @@ void ScriptWebShow(void) { #ifdef USE_SENDMAIL + +#ifdef ESP8266 void script_send_email_body(BearSSL::WiFiClientSecure_light *client) { +#else +void script_send_email_body(WiFiClient *client) { +#endif + uint8_t msect=Run_Scripter(">m",-2,0); if (msect==99) { char line[128];