Skip to content

Instantly share code, notes, and snippets.

@igrr
Created June 23, 2016 03:27
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save igrr/8f1b4a5771f0f34968c983e94c4c108d to your computer and use it in GitHub Desktop.
Save igrr/8f1b4a5771f0f34968c983e94c4c108d to your computer and use it in GitHub Desktop.
ESP8266 Arduino SMTPClient test
// Download SMTPClient library from https://github.com/gregington/SMTPClient
#include <ESP8266WiFi.h>
#include <Client.h>
#include <Mail.h>
#include <SMTPClient.h>
WiFiClient wifiClient;
SmtpClient client(&wifiClient, "smtp.163.com");
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
delay(100);
Serial.println();
Serial.println();
WiFi.persistent(false);
WiFi.mode(WIFI_STA);
WiFi.begin( ", " ");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("connected");
Serial.println("preparing email");
Mail mail;
mail.from("Some Sender <sender@example.com>");
mail.replyTo("noreply@example.com");
mail.to("Someone <someone@example.com>");
mail.to("Someone Else <someoneelse@example.com>");
mail.cc("Another <another@example.com>");
mail.bcc("Secret <secret@example.com>");
mail.subject("Hello there");
mail.body("I can send email from an Arduino!");
Serial.println("sending email");
client.send(&mail);
Serial.println("email sent");
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment