-
-
Save fzoccara/bc4eb748f6ff5355db3e4c2966aa7732 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 <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