Skip to content

SMTPClient library for ESP8266 Devices, Specificly Wemos D1 R1/Wi-Fi

License

Notifications You must be signed in to change notification settings

batuhantrkgl/ESP8266-D1_SMTPClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMTPClient Library

The SMTPClient library allows you to send emails using an ESP8266 microcontroller. It supports sending plain text emails as well as emails with attachments.

Features

  • Connect to an SMTP server
  • Authenticate using username and password
  • Send plain text emails
  • Send emails with attachments

Installation

  1. Download the library and place it in the libraries folder of your Arduino IDE.
  2. Include the library in your sketch:
#include <ESP8266_SMTPClient.h>

Usage

Initialize the Client

SMTPClient smtp;
smtp.begin("smtp.example.com", 587);
smtp.setCredentials("your_username", "your_password");

Send a Plain Text Email

bool success = smtp.sendMail("[email protected]", "[email protected]", "Subject", "Email body");
if (success) {
    Serial.println("Email sent successfully!");
} else {
    Serial.println("Failed to send email.");
}

Send an Email with Attachment

bool success = smtp.sendMailWithAttachment("[email protected]", "[email protected]", "Subject", "Email body", "/path/to/attachment.txt");
if (success) {
    Serial.println("Email with attachment sent successfully!");
} else {
    Serial.println("Failed to send email with attachment.");
}

API Reference

bool begin(const String& server, uint16_t port)

Initialize the SMTP client with the server address and port.

void setCredentials(const String& username, const String& password)

Set the username and password for SMTP authentication.

bool sendMail(const String& sender, const String& recipient, const String& subject, const String& message)

Send a plain text email.

bool sendMailWithAttachment(const String& sender, const String& recipient, const String& subject, const String& message, const String& filePath)

send a email with attachment.

License

This project is licensed under the MIT License

About

SMTPClient library for ESP8266 Devices, Specificly Wemos D1 R1/Wi-Fi

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages