Skip to content

Latest commit

 

History

History
53 lines (37 loc) · 1.74 KB

README.md

File metadata and controls

53 lines (37 loc) · 1.74 KB

arduino-smtpclient

Smtp client

This is an updated version from the one found originally at https://github.com/gregington/SMTPClient

Additions :

  • api to query error conditions

SMTPClient

An Arduino library to send emails to an SMTP server. Supports sending emails from an Arduino to an unauthenticated SMTP server. This library supports sending email through Ethernet, however it should also work with WiFi, but this has not been tested.

Usage

Client.h, Mail.h and SMTPClient.h need to be imported.

#import <Client.h>
#import <Mail.h>
#import <SMTPClient.h>

An instance of SMTPClient needs to be created with the server hostname or IP and the port where the SMTP server is located as well as the Client instance that will be used to make the connection. If the port is omitted, it is defaulted to port 25. In the following example, the client is an EthernetClient, but a WiFi or other client could be specified.

byte ip[] = { 192, 168, 0, 125 };
EthernetClient ethClient;
SmtpClient client(&ethClient, ip);

To send an email, an instance of the Mail class needs to be creaed and methods called to populate the object. At a minimum, at least one recipient and a from address are required. A maximum of 16 destination addresses are supported, with them being any combination of To, Cc or Bcc.

Mail mail;
mail.from("Some Sender <[email protected]>");
mail.replyTo("[email protected]");
mail.to("Someone <[email protected]>");
mail.to("Someone Else <[email protected]>");
mail.cc("Another <[email protected]>");
mail.bcc("Secret <[email protected]>");
mail.subject("Hello there");
mail.body("I can send email from an Arduino!");
client.send(&mail);