Tasmota/tasmota/sendemail.h

47 lines
1.1 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>
2020-04-12 18:28:19 +01:00
#ifdef ESP8266
2019-10-14 09:14:17 +01:00
#include "WiFiClientSecureLightBearSSL.h"
2020-11-28 11:46:17 +00:00
#endif // ESP8266
#ifdef ESP32
2020-04-12 18:28:19 +01:00
#include <WiFiClientSecure.h>
2020-11-28 11:46:17 +00:00
#endif // ESP32
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;
2020-04-12 18:28:19 +01:00
#ifdef ESP8266
2019-09-04 19:58:17 +01:00
// use bear ssl
2019-10-14 09:14:17 +01:00
BearSSL::WiFiClientSecure_light *client;
2020-11-28 11:46:17 +00:00
#endif // ESP8266
#ifdef ESP32
2020-04-12 18:28:19 +01:00
WiFiClient *client;
2020-11-28 11:46:17 +00:00
#endif // ESP32
2020-04-12 18:28:19 +01:00
2019-09-04 19:58:17 +01:00
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);
2019-10-18 10:33:52 +01:00
bool send(const String& from, const String& to, const String& subject, const char *msg);
2020-05-02 07:10:23 +01:00
void send_message_txt(char *msg);
2019-09-04 19:58:17 +01:00
~SendEmail() {client->stop(); delete client;}
};
#endif