Created
June 23, 2016 03:27
-
-
Save igrr/8f1b4a5771f0f34968c983e94c4c108d to your computer and use it in GitHub Desktop.
ESP8266 Arduino SMTPClient test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 <[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!"); | |
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