Tasmota/sonoff/sendemail.h

39 lines
1.0 KiB
C
Raw Normal View History

2019-09-04 19:58:17 +01:00
#ifndef __SENDEMAIL_H
#define __SENDEMAIL_H
//#define DEBUG_EMAIL_PORT
2019-10-14 09:14:17 +01:00
//#include <WiFiClient.h>
//#include <WiFiClientSecure.h>
2019-09-04 19:58:17 +01:00
#include <base64.h>
2019-10-14 09:14:17 +01:00
//#include <core_version.h>
#include "WiFiClientSecureLightBearSSL.h"
2019-09-04 19:58:17 +01:00
class SendEmail
{
private:
const String host;
const int port;
const String user;
const String passwd;
const int timeout;
const bool ssl;
const int auth_used;
2019-09-05 10:14:33 +01:00
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
WiFiClient* client;
#else
2019-09-04 19:58:17 +01:00
// use bear ssl
2019-10-14 09:14:17 +01:00
BearSSL::WiFiClientSecure_light *client;
2019-09-04 19:58:17 +01:00
#endif
String readClient();
void a3_to_a4(unsigned char * a4, unsigned char * a3);
int base64_encode(char *output, const char *input, int inputLen);
public:
SendEmail(const String& host, const int port, const String& user, const String& passwd, const int timeout, const int auth_used);
bool send(const String& from, const String& to, const String& subject, const String& msg);
~SendEmail() {client->stop(); delete client;}
};
#endif