Introduction: ESP8266 GMail Sender
Hello and welcome to my first Instructable.
I will show you how to send emails from any ESP8266 wifi module using Gmail server.
This instructable relies on Arduino core for ESP8266 WiFi chip,
which makes a self-contained microcontroller from it (no need of AT commands and master devices).
You can connect sensors and get notified by email about changes.
Before we begin
- Any ESP8266 (I'm using ESP8266-07 ebay link).
- In my case USB UART Board(I'm using FT232RL FTDI Serials Adapter Module ebay). Not needed if your board has usb port.
- Some jumper cables.
- WIFI router of course.
List may be incomplete.
Step 1: Gmail Account Setup
We are going to use SMTP to send messages.
Using SMTP Authentication we provide only email and password,
by default Google uses more complex verification methods so we need to change settings.
Go to your Google account settings and enable "Allow less secure apps" at the bottom of the page.
This mean apps only need your email and password when login to your gmail account.
If you concerned about security, just use different account.
Step 2: Edit Sketch
I wrote a little sketch which send one test message to check if all works as should.
When all software downloaded and installed:
- Unzip ESP8266_Gmail_Sender.zip
- Find and open ESP8266_Gmail_Sender.ino
- Set your wifi access point name (SSID) and password. Should be like this:
const char* ssid = "MyWiFi"; const char* password = "12345678";
- In setup() function find
if(gsender->Subject(subject)->Send("firstname.lastname@example.org", "Setup test"))
First parameter of Send() function is recipient email, second message text.
Change recipient from email@example.com to your email which will receive a message.
Subject function is optional! Subject sets once and stored until you change it.
You can send mails without subject or if it already set
- Now open Gsender.h tab
- We need Base64 encoded email address and password of gmail account which will be used to send emails.
You can use base64encode.org for encoding, result must be something like:
const char* EMAILBASE64_LOGIN = "Y29zbWkxMTExMUBnbWFpbC5jb20="; const char* EMAILBASE64_PASSWORD = "TGFzZGFzZDEyMzI=";
- Now set FROM field.
const char* FROM = "firstname.lastname@example.org";
That`s all for this part.
Step 3: Code Uploading and Testing
Save changes. Don`t forget to set your board in Tool menu.
Upload sketch to your ESP8266 board.
Open Serial monitor, board will print log messages.
That`s all I hope you will receive "Message send.". Thanks...
9 People Made This Project!
We have a be nice policy.
Please be positive and constructive.
Has anyone tried using this Gmail email sender with EthernetClient? I have tried using it but it does not get out of the while loop in !AwaitSMTPResponse(client, "235"). For some reason client.available() is never true and this gets into an infinite while loop. Any help would be greatly appreciated.
how can I pass the change of sensors to the e-mail.
is there a sample code. (push button open / closed).
I have arduino mega2560 and ESP8266 with ESP-01.
When attaching ESP-01 on arduino
RX ------ RX
TX ------- TX
VCC ----- 5V
GND ----- GND
after uploading will maked a error:
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
What should I do?