diff --git a/sonoff/WiFiClientSecureLightBearSSL.cpp b/sonoff/WiFiClientSecureLightBearSSL.cpp index 1b40a4661..20992a9dd 100644 --- a/sonoff/WiFiClientSecureLightBearSSL.cpp +++ b/sonoff/WiFiClientSecureLightBearSSL.cpp @@ -21,7 +21,8 @@ */ #include "my_user_config.h" -#ifdef USE_MQTT_TLS +//#ifdef USE_MQTT_TLS +#if defined(USE_MQTT_TLS) || defined (USE_SENDMAIL) //#define DEBUG_TLS diff --git a/lib/SENDMAIL/sendemail.h b/sonoff/sendemail.h similarity index 78% rename from lib/SENDMAIL/sendemail.h rename to sonoff/sendemail.h index 394612fc6..4b911c266 100755 --- a/lib/SENDMAIL/sendemail.h +++ b/sonoff/sendemail.h @@ -3,10 +3,12 @@ //#define DEBUG_EMAIL_PORT -#include -#include +//#include +//#include #include -#include +//#include + +#include "WiFiClientSecureLightBearSSL.h" class SendEmail { @@ -22,10 +24,7 @@ class SendEmail WiFiClient* client; #else // use bear ssl - // #include "WiFiClientSecureLightBearSSL.h" - // BearSSL::WiFiClientSecure_light *client; - BearSSL::WiFiClientSecure* client; - //WiFiClientSecure* client; + BearSSL::WiFiClientSecure_light *client; #endif String readClient(); void a3_to_a4(unsigned char * a4, unsigned char * a3); diff --git a/lib/SENDMAIL/sendemail.cpp b/sonoff/sendemail.ino similarity index 95% rename from lib/SENDMAIL/sendemail.cpp rename to sonoff/sendemail.ino index ab2c90ecd..3d4f59159 100755 --- a/lib/SENDMAIL/sendemail.cpp +++ b/sonoff/sendemail.ino @@ -1,10 +1,12 @@ +#ifdef USE_SENDMAIL + #include "sendemail.h" // enable serial debugging //#define DEBUG_EMAIL_PORT Serial 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()) + host(host), port(port), user(user), passwd(passwd), timeout(timeout), ssl(ssl), auth_used(auth_used), client(new BearSSL::WiFiClientSecure_light(1024,1024)) { } @@ -22,7 +24,7 @@ String SendEmail::readClient() return r; } -void SetSerialBaudrate(int baudrate); +//void SetSerialBaudrate(int baudrate); bool SendEmail::send(const String& from, const String& to, const String& subject, const String& msg) { @@ -42,21 +44,23 @@ bool SendEmail::send(const String& from, const String& to, const String& subject #if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) #else - client->setInsecure(); + //client->setInsecure(); + /* bool mfln = client->probeMaxFragmentLength(host.c_str(), port, 512); #ifdef DEBUG_EMAIL_PORT DEBUG_EMAIL_PORT.printf("MFLN supported: %s\n", mfln ? "yes" : "no"); #endif if (mfln) { client->setBufferSizes(512, 512); - } + }*/ #endif if (!client->connect(host.c_str(), port)) { #ifdef DEBUG_EMAIL_PORT - DEBUG_EMAIL_PORT.println("Connection failed"); + DEBUG_EMAIL_PORT.println("Connection failed: "); + //DEBUG_EMAIL_PORT.println (client->getLastSSLError()); #endif return false; } @@ -302,3 +306,5 @@ int SendEmail::base64_encode(char *output, const char *input, int inputLen) { return encLen; } #endif + +#endif // USE_SENDMAIL diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 32aeed73c..e59cfb3e7 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -2461,7 +2461,8 @@ String UrlEncode(const String& text) // sendmail [*:*:*:*:*:to:subject] data uses defines from user_config // sendmail currently only works with core 2.4.2 -#define SEND_MAIL_MINRAM 19*1024 + +#define SEND_MAIL_MINRAM 12*1024 uint16_t SendMail(char *buffer) { uint16_t count;