Merge pull request #8148 from gemu2015/sendmail_esp32

sendmail ESP32
This commit is contained in:
Theo Arends 2020-04-13 12:07:25 +02:00 committed by GitHub
commit 6030501673
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 3 deletions

View File

@ -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

View File

@ -8,7 +8,11 @@
#include <base64.h>
//#include <core_version.h>
#ifdef ESP8266
#include "WiFiClientSecureLightBearSSL.h"
#else
#include <WiFiClientSecure.h>
#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);

View File

@ -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);

View File

@ -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];