Update: 2020-05-28

Esp32 E-Mail als Arduino Tab.

Mail.ino

// ****************************************************************
// Sketch Esp32 E-mail senden Modular(Tab) nicht blockierend
// created: Jens Fleischer, 2018-07-09
// last mod: Jens Fleischer, 2020-05-28
// ****************************************************************
// Hardware: ESP32
// Software: Esp32 Arduino Core 1.0.0 - 1.0.4
// Software: https://smtp2go.com/
// Getestet auf: ESP32 NodeMCU-32s
/******************************************************************
  Copyright (c) 2018 Jens Fleischer. All rights reserved.

  This file is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  This file is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
*******************************************************************/
// Diese Version von Mail sollte als Tab eingebunden werden.
// #include <WebServer.h> oder #include <WiFi.h> muss im Haupttab aufgerufen werden
// Die Übergabe der Nachricht an "sendmails((string oder String-Object);" erfolgt als char oder String.
// Zum auswerten der Antwort vom Mailserver muss "emailResponse();" im loop(); stehen.
/**************************************************************************************/

#include "base64.h"

WiFiClient mailclient;

uint32_t mailbroadcastingTime;
bool mailresponse = true;

void sendmails(const String &message) {                       // SMTP2GO Free hat ein Limit von 25 E-Mails pro Stunde / 1.000 E-Mails pro Monat
  const char* user = "Username von smtpgo";                   // https://www.smtp2go.com
  const char* password = "Passwort von smtpgo";               // https://www.smtp2go.com
  const char* firstRecipient = "Emfänger Mail Adresse";       // Mailadresse des Empfängers eintragen
  const char* secondRecipient = "";                           // Mailadresse des zweiten Empfängers eintragen falls erforderlich
  const char* subject = "Wichtige Mitteilung! Von zu Hause!"; // Betreff
  const char* sender = "ESP32";
  const char* MAIL_SERVER = "mail.smtp2go.com";
  const uint16_t  PORT = 2525;                                // SMTP ports 25, 80, 587, 2525, 8025

  if (!mailclient.connect(MAIL_SERVER, PORT)) {
    DEBUG_F("Verbindung zu %s fehlgeschlagen.\n", MAIL_SERVER);
  }
  else {
    mailresponse = false;
    mailbroadcastingTime = millis();
    mailclient.printf("EHLO\nAUTH LOGIN\n%s\n%s\nMAIL From: <RbL@rbl.io>\nRCPT To: <%s>\nRCPT To:<%s>\n", base64::encode(user).c_str(), base64::encode(password).c_str(), firstRecipient, secondRecipient);
    mailclient.printf("DATA\nTo:<%s, %s>\nFrom: %s <RbL@rbl.io>\nSubject: %s %s\nContent-Type: text/plain;charset=utf-8\n", firstRecipient, secondRecipient, sender, sender, subject);
    mailclient.printf("Hallo!\nDer %s %s meldet.\n%s\n.\nQUIT\n", sender, WiFi.getHostname(), message.c_str());
  }
}

void emailResponse() {
  if (!mailresponse) {
    static bool mailerror;
    if (millis() - mailbroadcastingTime > 3000) {
      if (!mailerror) {
        DEBUG_P("Mail Client Timeout !");
        mailerror = true;
        sendmails("Fehler beim Mail versenden.");      // Bei Zeitüberschreitung wird eine Zweite Mail gesendet
      }
      return;
    }
    if (mailclient.available()) {
      String line = mailclient.readStringUntil('\n');
      if (line.startsWith("250 OK id=")) {            // wenn Zeile der Antwort mit "250 OK id=" beginnt war das Senden erfolgreich
        DEBUG_F("Antwort vom Mailserver in: %ld ms\n", (millis() - mailbroadcastingTime));
        mailclient.stop();
        mailerror = false;
        mailresponse = true;
      }
    }
  }
}

Der Aufruf zum senden von E-Mails kann aus jedem beliebigen Programmteil erfolgen.
Du kannst "sendmails();" überall in deinem Sketch einbinden.

Achtung!
SMTP2GO Free hat ein Limit von 25 E-Mails pro Stunde / 1.000 E-Mails pro Monat.
Deshalb die Funktion "sendmails();" niemals unlimitiert aufrufen.

Beispiel:

******************** Text & Datum/Uhrzeit *********************

void setup() {
  ........
  sendmails((String)"Systemstart " + localTime());
  ........
}