Sending Email using Arduino and ESP8266 Wi-Fi Module

Published  March 30, 2016   57
S Saddam
Author
Sending Email using Arduino Uno and ESP8266 Wi-Fi Module

We are moving towards the World of Internet of Things (IoT). This technology plays a very important role in the Electronics and Embedded system. Sending an Email from any Microcontroller or Embedded system is very basic thing, which is required in IoT. So in this article, we will learn “How to send an Email using Wi-Fi and Arduino”.

For sending Email via Wi-Fi module and Arduino, first of all we need to have an Email account. So user can create email account at smtp2go.com. After signup, remember your new email address and password.

You can also learn How to Call and Message using Arduino.

 

We can understand the whole process in below Steps:

Step 1: First arrange all the required Components.

  • Arduino UNO
  • ESP8266 Wi-Fi module
  • USB Cable
  • Laptop   
  • 16x2 LCD (optional)
  • 10K POT   (optional)
  • Power supply
  • Connecting wires

Wi-Fi Module ESP8266:

ESP8266 Wi-Fi-module

 

Step 2: In this step we will connect ESP8266 Wi-Fi module with Arduino and give it power supply from 3.3v pin of Arduino.

Arduino and Wifi module fritzing-circuit

 

Step 3: In this step, we need to sign-up for Email address and Password (smtp2go.com). smtp2go.com provides the email services, to send the emails using outgoing email server.

Send Email using Arduino smtp2go.com signup

 

Step 4: We will need Username and Password in base64 encoded format with utf-8 character set. For converting the Email and Password in base64 encoded format use below given link. Keep the encoded username and password handy, we need it in our program to login at smtp2go.com.

https://www.base64encode.org/

Send Email using Arduino base64_encode

 

Step 5: Now start writing code for sending Email. ‘Programming Explanation’ and Code is given at the end.

 

Circuit Explanation:

Circuit is very simple, for this project we only need Arduino and ESP8266 Wi-Fi module. A 16x2 LCD is also connected for displaying the status messages. This LCD is optional. ESP8266’s Vcc and GND pins are directly connected to 3.3V and GND of Arduino and CH_PD is also connected with 3.3V.

Tx and Rx pins of ESP8266 are directly connected to pin 2 and 3 of Arduino. And Pin 2 of Arduino is also shorted with Tx pin (Pin 1) of Arduino. This pin is shorted for displaying response of ESP8266 directly on Serial monitor of Arduino. Software Serial Library is used to allow serial communication on pin 2 and 3 of Arduino.

Send Email using Arduino and Wifi Module Circuit Diagram

Note: For watching the response of ESP8266 on Serial Monitor, don’t initialise the Serial.begin(9600) function.

 

Programming Explanation:

1. In programming part first we include libraries and define pins for LCD & software serial communication. By default Pin 0 and 1 of Arduino are used for serial communication but by using SoftwareSerial library, we can allow serial communication on other digital pins of the Arduino.

 

2. void connect_wifi(String cmd, int t) Function is defined to Connect the Wi-Fi module to the Internet.

void connect_wifi(String cmd, int t)
{
  int temp=0,i=0;
  while(1)
  {
    Serial1.println(cmd); 
    while(Serial1.available())
    {
      if(Serial1.find("OK"))
      ... .... ....
      ... .....

3. After it connect module to SMTP server by using given commands:

 lcd.print("Configuring Email..");
  Serial1.println("AT+CIPSTART=4,\"TCP\",\"mail.smtp2go.com\",2525");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,20");
  delay(2000);
  Serial1.println("EHLO 192.168.1.123");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,12");

Note: Many email servers will not accept email from a non-commercial, dhcp-issued ip address.

 

4. Now we will try to Login at smtp2go.co, using the base64 encoded User name and password, which we have derived in Step 4 above.

lcd.print("Try To Login.....");
  Serial1.println("AUTH LOGIN");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,30");
  delay(2000);
  Serial1.println("c2FkZGFtNDIwMUBnbWFpbC5jb20=");     //base64 encoded username
  delay(2000);
  Serial1.println("AT+CIPSEND=4,18");
  delay(2000);
  Serial1.println("Y2lyY3VpdDQyMDE=");                //base64 encoded password

5. After this, enter your main message that user want to send. And send this email by ending line (sending)  ‘.’

  Serial1.println("Testing Success");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,3");
  delay(2000);
  Serial1.println('.');
  delay(10000);
  Serial1.println("AT+CIPSEND=4,6");
  delay(2000);
  Serial1.println("QUIT");
  ... .....
  .......

Other functions and Code are self-explanatory and easy to understand. 

Code

#include<LiquidCrystal.h>
LiquidCrystal lcd(14,15,16,17,18,19);

#include <SoftwareSerial.h>
SoftwareSerial Serial1(2, 3); // RX, TX

boolean No_IP=false;
String IP="";

void check4IP(int t1)
{
  int t2=millis();
  Serial1.flush();
  while(t2+t1>millis())
  {
    while(Serial1.available()>0)
    {
      if(Serial1.find("WIFI GOT IP"))
      {
        No_IP=true;
      }
    }
  }
}

void get_ip()
{
  IP="";
  char ch=0;
  while(1)
  {
    Serial1.println("AT+CIFSR");
    while(Serial1.available()>0)
    {
      if(Serial1.find("STAIP,"))
      {
        delay(1000);
        Serial.print("IP Address:");
        while(Serial1.available()>0)
        {
          ch=Serial1.read();
          if(ch=='+')
          break;
          IP+=ch;
        }
      }
      if(ch=='+')
      break;
    }
    if(ch=='+')
    break;
    delay(1000);
  }
  Serial.print(IP);
  Serial.print("Port:");
  Serial.println(80);
}

void connect_wifi(String cmd, int t)
{
  int temp=0,i=0;
  while(1)
  {
    Serial1.println(cmd); 
    while(Serial1.available())
    {
      if(Serial1.find("OK"))
      i=8;
    }
    delay(t);
    if(i>5)
    break;
    i++;
  }
  if(i==8)
  Serial.println("OK");
  else
  Serial.println("Error");
}

void setup()
{
  Serial1.begin(9600);
    // Serial.begin(9600);
     lcd.begin(16,2);
     lcd.print("Sending Email by");
     lcd.setCursor(0,1);
     lcd.print(" Arduino & WIFI ");
     delay(2000);
     lcd.clear();
     lcd.print("  Circuit Digest  ");
     delay(2000);
     lcd.clear();
     lcd.print("Finding ESP8266");
     connect_wifi("AT",100);
     connect_wifi("ATE1",100);
     lcd.clear();
     lcd.print("Connected");
     delay(1000);
     connect_wifi("AT+CWMODE=3",100);
     connect_wifi("AT+CWQAP",100);  
     connect_wifi("AT+RST",5000);
     lcd.clear();
     lcd.print("Connecting WiFi");
     check4IP(5000);
     if(!No_IP)
     {
        Serial.println("Connecting Wifi....");
        connect_wifi("AT+CWJAP=\"1st floor\",\"muda1884\"",7000);    //provide your WiFi username and password here
      }
      else
        {
        }
      lcd.clear();
      lcd.print("WIFI Connected...");
      Serial.println("Wifi Connected");
      delay(1000);
      lcd.clear();
      lcd.print("Getting IP Add.");
      Serial.println("Getting IP Address....");
      get_ip();
      delay(1000);
      lcd.clear();
      lcd.print("IP:");
      lcd.print(IP);
      lcd.setCursor(0,1);
      lcd.print("PORT: 80");
      connect_wifi("AT+CIPMUX=1",100);
      connect_wifi("AT+CIPSERVER=1,80",100);
      delay(2000);
      lcd.clear();
      lcd.print("Configuring Email..");
  Serial1.println("AT+CIPSTART=4,\"TCP\",\"mail.smtp2go.com\",2525");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,20");
  delay(2000);
  Serial1.println("EHLO 192.168.1.123");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,12");
  delay(2000);
  lcd.clear();
  lcd.print("Try To Login.....");
  Serial1.println("AUTH LOGIN");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,30");
  delay(2000);
  Serial1.println("c2FkZGFtNDIwMUBnbWFpbC5jb20=");     //base64 encoded username
  delay(2000);
  Serial1.println("AT+CIPSEND=4,18");
  delay(2000);
  Serial1.println("Y2lyY3VpdDQyMDE=");                    //base64 encoded password
  lcd.clear();
  lcd.print("Login Success");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,34");
  delay(2000);
  Serial1.println("MAIL FROM:<saddam4201@ gmail.com>");  // use your email address
  delay(2000);  
  Serial1.println("AT+CIPSEND=4,32");
  delay(2000);
  lcd.clear();
  lcd.print("Seniding Email 2");
  lcd.setCursor(0,1);
  lcd.print("Saddam4201@ gmail");
  Serial1.println("RCPT To:<saddam4201@ gmail.com>");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,6");
  delay(2000);
  Serial1.println("DATA");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,24");
  delay(2000);
  Serial1.println("Testing Success");
  delay(2000);
  Serial1.println("AT+CIPSEND=4,3");
  delay(2000);
  Serial1.println('.');
  delay(10000);
  Serial1.println("AT+CIPSEND=4,6");
  delay(2000);
  Serial1.println("QUIT");
  delay(2000);
  lcd.clear();
  lcd.print("Email Sent...");
}

void loop()
{
   
}

Video

Comments

Submitted by Rohit Rajapure on Tue, 04/05/2016 - 15:49

Permalink

Hello Saddam,
Thank you for posting this project.
I'm new to the ESP8266 and ARDUINO UNO, Can you please share the step by step procedure followed by you during the project.

Thanks in advance

Hi,

I am beginner for embedded systems and working on IoT. I have interfaced arduino uno with ESP8266 wifi module and 16*2 LCD. Now i have to type text in textbox of HTML page and hen i click on submit button ,it should get displayed on LCD.

Please reply

Thanks in advance

Submitted by Yoann27 on Sun, 05/22/2016 - 16:19

Permalink

Hi, my LCD ago marked 'GET WIFI IP "and the program runs in a loop by giving me the IP address of the wireless card or something else. Why?

Hyy Maddy...
I don't know why code is showing error in the line connect_wifi("AT+CWJAP=\"1st floor\",\"muda1884\"",7000);
Here my code is connect_wifi("Android AP_2704",kavita123); telling "my password" was not declared in this scope.

Please help me out.

Submitted by FRANKLIN BONFIM on Mon, 07/18/2016 - 03:52

Permalink

I have this problem and I am not getting correct.

"
[...]
> IPSEND=4,34

busy s...

Recv 18 bytes

SEND OK

+IPD,4,35:535 Incorrect authentication data
MAIL FROM:<fklbonfim@gmail.com>

ERROR
AT+CIPSEND=4,32

OK
> T+CIPSEND=4,6

busy s...

Recv 32 bytes

SEND OK

+IPD,4,26:500 unrecognized command
AT+CIPSEND=4,24

OK
> END=4,3

busy s...

Recv 24 bytes

SEND OK

+IPD,4,26:500 unrecognized command
AT+CIPSEND=4,6

OK
>
Recv 6 bytes

SEND OK

+IPD,4,26:500 unrecognized command"

Submitted by James on Tue, 08/30/2016 - 04:09

Permalink

Hi!
Having fun working this through. I don't have an LCD, and you mention "Note: For watching the response of ESP8266 on Serial Monitor, don’t initialise the Serial.begin(9600) function.". Can someone explain how to do that in the code?
MANY thanks!

Submitted by Marco on Fri, 09/09/2016 - 19:42

Permalink

Hi,
thanks for writing this tutorial. But i got a problem.

Im always stuck on "Getting IP Add."
The eps is visible in my router overview and also got an ip adress.

AT+CIFSR

192.168.4.1
192.168.178.48

OK

but it wont stop asking for a ip adress.
What am i doing wrong?

Submitted by Apostolis on Tue, 09/13/2016 - 22:40

Permalink

Thank you sir.. I can confirm that this is working. Simple and easy..just follow the steps. I set it up to sent me an email when there is an alarm trigger at home.I wrote the commands in an progmem array and used a for function to call them so they dont use ram.The only problem is that the email applications dont refresh/synchronise on smartphones to often.

If your phone doesn't check mail too often, send the email to a email-to-SMS gateway. Most cell providers have a way to do that. Research it.

Submitted by CLAUDIO on Tue, 09/20/2016 - 22:51

Permalink

Very goog job ......BUT....

if i give the AT command by hand for the '.' (DOT, for terminate the text of the email) in the serial monitor works and send me an email

BUT if i put this in the code doesn't work see below....please help me thanks a lot

Serial1.println("AT+CIPSEND=3");
delay(2000);
Serial1.println('.');

Submitted by CLAUDIO on Wed, 09/21/2016 - 00:52

In reply to by CLAUDIO

Permalink

so when you write in serial monitor AT command you must digit AT+CIPSEND=3 and it works

but when you write in your code you must write this
Serial1.println("AT+CIPSEND=4,3");

Submitted by Ris on Tue, 11/15/2016 - 13:43

Permalink

I get this in my serial monitor:

ón't use rtc mem data
rl�‚slÌÿ
Ai-Thinker Technology Co.,Ltd.

invalid
WIFI CONNECTED
WIFI GOT IP
AT+CWJAP="Redmi","efdfdf"

WIFI DISCONNECT
AT+CWJAP="Redmi","efdfdf"

busy p...
AT+CWJAP="Redmi","efdfdf"

busy p...
+CWJAP:1

FAIL
AT+CWJAP="Redmi","efdfdf"

WIFI CONNECTED
WIFI GOT IP

OK
AT+CWJAP="Redmi","efdfdf"

WIFI DISCONNECT
AT+CIFSR

busy p...
AT+CIFSR

busy p...
AT+CIFSR

busy p...
AT+CIFSR

busy p...
AT+CIFSR

busy p...
+CWJAP:1

FAIL
AT+CIFSR

+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:99:87:c7"
+CIFSR:STAIP,"0.0.0.0"
+CIFSR:STAMAC,"18:fe:34:99:87:c7"

and thereafter just the following text repeatedly, with no more progress.

OK
AT+CIFSR

+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:99:87:c7"
+CIFSR:STAIP,"0.0.0.0"
+CIFSR:STAMAC,"18:fe:34:99:87:c7"

OK
AT+CIFSR

+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:99:87:c7"
+CIFSR:STAIP,"0.0.0.0"
+CIFSR:STAMAC,"18:fe:34:99:87:c7"

...

What should I do?

Submitted by karim on Mon, 11/28/2016 - 23:36

Permalink

hi saddam ,i dont know where i put my username and password in this:
connect_wifi("AT+CWJAP=\"1st floor\",\"muda1884\"",7000);

Submitted by Pranav Sharma on Thu, 12/22/2016 - 18:35

Permalink

I am getting some error in SoftwareSerial Serial1 saying conflicting declaration ''SoftwareSerial Serial1'
I am using arduino mega 2560

Submitted by mosab on Thu, 12/29/2016 - 20:42

Permalink

hello mr saddam
thank for your info
i have tried set the arduino to send distance from ultrasonic sensor to webpage
but at first i would like to check if my ESP8266 coneccted properly
i have used your code but when i run it i got thoese on the computer secree :

AT
AT
AT
AT
AT
AT
AT
ATE1
ATE1
ATE1
ATE1
ATE1
ATE1
ATE1
AT+CWMODE=3
AT+CWMODE=3
AT+CWMODE=3
AT+CWMODE=3
AT+CWMODE=3
AT+CWMODE=3
AT+CWMODE=3
AT+CWQAP
AT+CWQAP
AT+CWQAP
AT+CWQAP
AT+CWQAP
AT+CWQAP
AT+CWQAP
AT+RST
AT+RST
AT+RST
AT+RST
AT+RST
AT+RST
AT+RST
can you please let me know the reason and how to solve this or anyone can guide me on that ?

Submitted by Mario on Sun, 01/01/2017 - 05:50

Permalink

Hello mr saddam thank for your info
i have this problem
+IPD,4,182:250-mail.smtp2go.com Hello 192.168.1.123 [187.163.212.60]
250-SIZE 52428800
250-8BITMIME
250-DSN
250-PIPELINING
250-AUTH CRAM-MD5 PLAIN LOGIN
250-STARTTLS
250-PRDR
250 HELP
AT+CIPSEND=4,12
OK
>
Recv 12 bytes
SEND OK
+IPD,4,18:334 VXNlcm5hbWU6
AT+CIPSEND=4,30
OK
>
Recv 30 bytes
SEND OK
+IPD,4,18:334 UGFzc3dvcmQ6
AT+CIPSEND=4,18
OK
>
Recv 18 bytes
SEND OK
+IPD,4,30:235 Authentication succeeded
AT+CIPSEND=4,34
OK
> T+CIPSEND=4,32
busy s...
Recv 34 bytes
SEND OK
+IPD,4,8:250 OK
RCPT To:<ggbathory@gmail.com>
ERROR
AT+CIPSEND=4,6
OK
>
Recv 6 bytes
SEND OK
+IPD,4,26:500 unrecognized command
AT+CIPSEND=4,24
OK
> END=4,3
busy s...
Recv 24 bytes
SEND OK
+IPD,4,26:500 unrecognized command
.
ERROR
AT+CIPSEND=4,6
OK
>
Recv 6 bytes
SEND OK
+IPD,4,26:500 unrecognized command

Submitted by Shaheer on Fri, 01/06/2017 - 23:59

Permalink

Sir I found your tutorial very helpful. I have encountered a slight problem. When i send the EHLO command i dont get any response. Is there any need for port forwarding before i make this connection? Or is it something else?
Thank you.

Submitted by piyush charpe on Sat, 01/14/2017 - 18:53

Permalink

hello ,
your privious projects were really awesome, i m done with this project can u please make a tutorial on how to make a call using esp8266.
it will be very helpfull to explore IOT more.

Submitted by Leon on Tue, 01/24/2017 - 16:14

Permalink

Should I use SMTP user or App user of smtp2go??
I'm using encoded SMTP user but I get auth error:

250-SIZE 52428800
250-8BITMIME
250-DSN
250-PIPELINING
250-AUTH CRAM-MD5 PLAIN LOGIN
250-STARTTLS
250-PRDR
250 HELP
AUTH LOGIN

ERROR
AT+CIPSEND=4,30

Also in Serial1.println("EHLO 192.168.1.123");
What's that IP address?

Submitted by Mayank Lohani on Sat, 01/28/2017 - 12:47

Permalink

Sending Email by
Arduino & WIFI
Mayank
Finding ESP8266
OK
OK
Connected
OK
OK
OK
Connecting WIFI()
Connecting Wifi....
OK
Wifi Connected
Getting IP Address.

it is not obtaining any ip. plzz help me to fix this

Submitted by Sven on Mon, 02/20/2017 - 22:29

Permalink

Hi,
when I am sending DATA I got the answer +IPD,4,47:501 <sDATA: "@" or "." expected after "sDATA" and the following text messages are unrecognized commands. Can someone help me to solve the problem?
Thanks!

Submitted by hemanth on Sat, 03/11/2017 - 17:26

Permalink

iam doing a mini project on security system USING(ardino uno , ultrasonic sensor , buzzer, esp8266 wifi module ) (i need to get message to mobile from the urdino uno while somthing is dittected ) how to i procead i completed with decting and now i need to get message any help is usefull
Thanks

Submitted by nazmi on Fri, 03/17/2017 - 08:51

Permalink

Hi Mr Maddy..how to fix this?it display

Wifi Connected

ERROR
Getting IP Address....

ERROR
AT+CIFSR

+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:f2:79:5a"
+CIFSR:STAIP,"192.168.43.116"
+CIFSR:STAMAC,"18:fe:34:f2:79:5a"

Submitted by Frank Bakker on Thu, 04/20/2017 - 17:05

Permalink

Would it be possible to make this work for a ethernet shield?
I need it for a greenhouse hobby.
Can you please help me i am a absoluut beginner..
i have looked to change it my self but i am stuck .

Thanks Frank

Submitted by john shead on Mon, 05/08/2017 - 06:40

Permalink

I just used part of your code to send email from a ATWINC1500 on a Adafruit Feather M0.
it works well. I did not know SMPT protocol or that it would be easy to do until I read your explanation.

Submitted by Henrique Thomazi on Wed, 07/05/2017 - 00:29

Permalink

So, I'm getting this

cmlxdWV0aG9tQGdtYWlsLmNvbQ==

ERROR
AT+CIPSEND=4,17

OK
> AT+CIPSEND=4,32

busy s...

Anjd I believe that chains other error messages I get after that. What should I do?

Submitted by Alain on Wed, 07/05/2017 - 12:44

Permalink

Very good project but now we have a full equiped ES8266, no need to have an Arduino UNO.

Anybody has the sketck to send a mail with only ESP8266 ?

Thanks in advance
Regards
Alain

Submitted by denish on Sat, 07/08/2017 - 17:40

Permalink

I'm not getting IP addressing, after IP addressing message not getting IP address. So please help me

void get_ip()

{
IP=" ";
char ch=0;
while(1)
{
Serial1.println("AT+CIFSR");
while(Serial1.available()>0)
{
if(Serial1.find("STAIP,"))
{
delay(1000);
Serial.print("IP Address:");
while(Serial1.available()>0)
{
ch=Serial1.read();
if(ch=='+')
break;
IP+=ch;
}
}
if(ch=='+')
break;
}
if(ch=='+')
break;
delay(1000);
}
lcd.clear();
lcd.print(IP);
lcd.setCursor(0,1);
lcd.print("Port: 80");
Serial.print(IP);
Serial.print("Port:");
Serial.println(80);
delay(1000);
}

OUTPUT:
OK
OK
OK
OK
OK
Connecting Wifi....
OK
Wifi Connected
Getting IP Address....

Submitted by Ankita Rupam on Wed, 07/26/2017 - 19:49

Permalink

Hey I have bolt in which will do module is present so can I use bolt with arudino to make this project if u solve my I am very thankful

Submitted by Shreedeep Gang… on Wed, 08/16/2017 - 01:40

Permalink

Everything is working perfect except sending the mail. Although it is being displayed in the Serial Monitor that the email is sent but it has not.

#include <SoftwareSerial.h>
SoftwareSerial esp8266(6,7); // RX, TX
boolean No_IP=false;
String IP="";
String cmd="",str="";
void check4IP(int t1)
{
int t2=millis();
esp8266.flush();
while(t2+t1>millis())
{
while(esp8266.available()>0)
{
if(esp8266.find("WIFI GOT IP"))
{
No_IP=true;
}
}
}
}
void get_ip()
{
IP="";
char ch=0;
while(1)
{
esp8266.println("AT+CIFSR");
while(esp8266.available()>0)
{
if(esp8266.find("STAIP,"))
{
delay(1000);
Serial.print("IP Address:");
while(esp8266.available()>0)
{
ch=esp8266.read();
if(ch=='+')
break;
IP+=ch;
}
}
if(ch=='+')
break;
}
if(ch=='+')
break;
delay(1000);
}
Serial.print(IP);
Serial.print("Port:");
Serial.println(80);
}
void connect_wifi(String cmd, int t)
{
int temp=0,i=0;
while(1)
{
esp8266.println(cmd);
while(esp8266.available())
{
if(esp8266.find("OK"))
i=8;
}
delay(t);
if(i>5)
break;
i++;
}
if(i==8)
Serial.println("OK");
else
Serial.println("Error");
}
void setup()
{
esp8266.begin(9600);
Serial.begin(9600);
// lcd.begin(16,2);
Serial.println("Sending Email by");
delay(1000);
// lcd.setCursor(0,1);
Serial.println(" Arduino & WIFI ");
delay(2000);
// lcd.clear();
// lcd.print(" Circuit Digest ");
// delay(2000);
// lcd.clear();
Serial.print("Finding ESP8266");
connect_wifi("AT",100);
connect_wifi("ATE1",100);
//lcd.clear();
//lcd.print("Connected");
delay(1000);
connect_wifi("AT+CWMODE=3",100);
connect_wifi("AT+CWQAP",100);
connect_wifi("AT+RST",5000);
//lcd.clear();
Serial.print("Connecting WiFi");
check4IP(5000);
if(!No_IP)
{
Serial.println("Connecting Wifi....");
connect_wifi("AT+CWJAP=\"TP-LINK_PIUMIU\",\"piumiu123#\"",7000); //provide your WiFi username and password here
}
else
{
}
//lcd.clear();
//lcd.print("WIFI Connected...");
Serial.println("Wifi Connected");
delay(1000);
//lcd.clear();
//lcd.print("Getting IP Add.");
Serial.println("Getting IP Address....");
get_ip();
delay(1000);
// lcd.clear();
// lcd.print("IP:");
// lcd.print(IP);
// lcd.setCursor(0,1);
// lcd.print("PORT: 80");
connect_wifi("AT+CIPMUX=1",100);
connect_wifi("AT+CIPSERVER=1,80",100);
delay(2000);
//lcd.clear();
Serial.print("Configuring Email..");
esp8266.println("AT+CIPSTART=4,\"TCP\",\"mail.smtp2go.com\",2525");
delay(2000);
esp8266.println("AT+CIPSEND=4,20");
delay(2000);
esp8266.println("EHLO 192.168.0.104");
delay(2000);
esp8266.println("AT+CIPSEND=4,12");
delay(2000);
//lcd.clear();
Serial.print("Try To Login.....");
esp8266.println("AUTH LOGIN");
delay(2000);
esp8266.println("AT+CIPSEND=4,34");
delay(2000);
esp8266.println("Zm9yZXN0Z3VtcC44M0BnbWFpbC5jb20="); //base64 encoded username
delay(2000);
esp8266.println("AT+CIPSEND=4,18");
delay(2000);
esp8266.println("cGl1bWVvd2FtcmE="); //base64 encoded password
//lcd.clear();
Serial.print("Login Success");
delay(2000);
//str="MAIL FROM:<mishtudeep@gmail.com>";
//cmd = "AT+CIPSEND=4,";
//cmd += String(str.length());
esp8266.println("AT+CIPSEND=4,36");
delay(2000);
esp8266.println("MAIL FROM:<forestgump.83@gmail.com>"); // use your email address
delay(2000);
esp8266.println("AT+CIPSEND=4,32");
delay(2000);
//lcd.clear();
Serial.println("Seniding Email to");
//lcd.setCursor(0,1);
Serial.println("sree060796@gmail.com");
esp8266.println("RCPT To:<sree060796@gmail.com>");
delay(2000);
esp8266.println("AT+CIPSEND=4,6");
delay(2000);
esp8266.println("DATA");
delay(2000);
esp8266.println("AT+CIPSEND=4,17");
delay(2000);
esp8266.println("Testing Success");
delay(2000);
esp8266.println("AT+CIPSEND=4,3");
delay(2000);
esp8266.println('.');
delay(10000);
esp8266.println("AT+CIPSEND=4,6");
delay(2000);
esp8266.println("QUIT");
delay(2000);
//lcd.clear();
Serial.println("Email Sent...");
}
void loop()
{

}

hiii gango ,
in monitor serial i have :
Sending Email by
Arduino & WIFI
Finding ESP8266Error
Error
Error
Error
Error
Connecting WiFi

please help me! what is the problem

Submitted by jacem on Wed, 08/30/2017 - 03:00

Permalink

Hi,
Thanks for this tutoriel
I made an account in smtp2go and I use AT commands to send an email with my arduino uno and my esp8266 module
All steps are successfully done, but when I check my gmail account, I cannot find any email (even in Spams)
Is this issue related to only gmail or there is another problem ?

Submitted by sanjeev kumar on Sat, 12/16/2017 - 16:18

Permalink

hi i have done the connection according to ur circuit only and i have added my base encoded paswword and email id but still when i upload the code the initial commands for 9600 bps is not shown in the serial terminal

Submitted by yasmina on Wed, 04/11/2018 - 17:07

Permalink

when I try to create an account at the SMTP2GO site it says that it is not available in my country..are there any other alternatives which have a very close functionality to this one?

Submitted by DIego on Sat, 04/21/2018 - 07:42

Permalink

Hi, nice project.
Well, i've been trying to make this work for a few days, but i got this problem. Everything works fine until this point.

+IPD,4,25:501 Invalid base64 data
AT+CIPSEND=4,17

OK
>
Recv 17 bytes

SEND OK

+IPD,4,26:500 unrecognized command
AT+CIPSEND=4,3

OK
>
Recv 3 bytes

SEND OK

+IPD,4,26:500 unrecognized command
AT+CIPSEND=4,6

Do you know what it could be?
Thank you a lot

Submitted by Muhammad Syukran on Tue, 05/01/2018 - 12:04

Permalink

Hi,

I am unable to load the code from arduino ide to esp8266
Sketch uses 232,505 bytes (53%) of program storage space. Maximum is 434,160 bytes.
Global variables use 32,504 bytes (39%) of dynamic memory, leaving 49,416 bytes for local variables. Maximum is 81,920 bytes.

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

Need URGENT Help, someone can directly contact me on msyukahn94@gmail.com

Please HELP here...

Submitted by Jiya Uddin Ahmad on Sun, 06/03/2018 - 05:13

Permalink

Thank you so much for such a useful project demonstration.Now,using this exact process,can I email a photo stored in my sd card attached to the arduino board?
If yes,please give related information....Thanks a lot....

Hi i am everything is working until this point:

+IPD,4,25:501 Invalid base64 data
MAIL FROM:<jayjames.tyson @gmaill.com>

ERROR
AT+CIPSEND=4,32

 

what can i do to fix it?