### Install EMailSender via PlatformIO Source: https://github.com/xreef/emailsender/blob/master/README.md Add the library dependency to your platformio.ini file. ```ini lib_deps = xreef/EMailSender@^4.1.3 ``` -------------------------------- ### Enable Debug Mode Source: https://github.com/xreef/emailsender/blob/master/README.md Uncomment these definitions in EMailSenderKey.h to output SMTP communication to the Serial Monitor. ```cpp #define EMAIL_SENDER_DEBUG #define DEBUG_PRINTER Serial ``` -------------------------------- ### Send Simple Email from ESP32 Source: https://github.com/xreef/emailsender/blob/master/README.md Basic implementation for sending an email via Gmail SMTP on an ESP32 device. ```cpp #include #include const char* ssid = "YOUR_SSID"; const char* password = "YOUR_PASSWORD"; // Gmail SMTP configuration EMailSender emailSend("your.email@gmail.com", "your_app_password", "your.email@gmail.com", "Your Name", "smtp.gmail.com", 587); // Port 587 for STARTTLS void setup() { Serial.begin(115200); // Connect to WiFi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nWiFi Connected!"); // Prepare email message EMailSender::EMailMessage message; message.subject = "Test Email"; message.message = "Hello from ESP32!"; // Send email EMailSender::Response resp = emailSend.send("recipient@example.com", message); Serial.println("Sending status: "); Serial.println(resp.code); Serial.println(resp.desc); Serial.println(resp.status); } void loop() { // Nothing here } ``` -------------------------------- ### Send HTML Email to Multiple Recipients Source: https://github.com/xreef/emailsender/blob/master/README.md Configure message MIME type to HTML and send to an array of recipients. ```cpp EMailSender::EMailMessage message; message.subject = "HTML Email Test"; message.message = "

Hello!

This is an HTML email.

"; message.mime = MIME_TEXT_HTML; // Set MIME type to HTML // Multiple recipients const char* recipients[] = { "recipient1@example.com", "recipient2@example.com", "recipient3@example.com" }; EMailSender::Response resp = emailSend.send(recipients, 3, message); ``` -------------------------------- ### Send Email with CC and BCC Source: https://github.com/xreef/emailsender/blob/master/README.md Specify counts for To, Cc, and Bcc recipients in the send method. ```cpp // Array with To, Cc, and Bcc addresses const char* allRecipients[] = { "to@example.com", // To (1) "cc@example.com", // Cc (1) "bcc@example.com" // Bcc (1) }; // send(recipients, numTo, numCc, numBcc, message) EMailSender::Response resp = emailSend.send(allRecipients, 1, 1, 1, message); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.