Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By asmallri
#40293
Erni wrote:Hi asmallri,

This is the sketch:

Code: Select all#include <ESP8266WiFi.h>
const char* SSID = "SSID";
const char* PASS = "pass";
char server[] = "mail.smtpcorp.com";

WiFiClient client;
void setup()
{
  Serial.begin(115200);
  delay(10);
  Serial.println("");
  Serial.println("");
  Serial.print("Connecting To ");
  Serial.println(SSID);
  WiFi.begin(SSID, PASS);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi Connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  byte ret = sendEmail();
}

void loop()
{
}

byte sendEmail()
{
  byte thisByte = 0;
  byte respCode;

  if (client.connect(server, 2525) == 1) {
    Serial.println(F("connected"));
  } else {
    Serial.println(F("connection failed"));
    return 0;
  }
  if (!eRcv()) return 0;

  Serial.println(F("Sending EHLO"));
  client.println("EHLO www.example.com");
  if (!eRcv()) return 0;
  Serial.println(F("Sending auth login"));
  client.println("auth login");
  if (!eRcv()) return 0;
  Serial.println(F("Sending User"));
  // Change to your base64, ASCII encoded user
  client.println("xxxxxx"); //<---------User
  if (!eRcv()) return 0;
  Serial.println(F("Sending Password"));
  // change to your base64, ASCII encoded password
  client.println("yyyyyyyy");//<---------Passw
  if (!eRcv()) return 0;
  Serial.println(F("Sending From"));
  // change to your email address (sender)
  client.println(F("MAIL From: cccc@gmail.com"));
  if (!eRcv()) return 0;
  // change to recipient address
  Serial.println(F("Sending To"));
  client.println(F("RCPT To: xxx@yormai.com"));
  if (!eRcv()) return 0;
  Serial.println(F("Sending DATA"));
  client.println(F("DATA"));
  if (!eRcv()) return 0;
  Serial.println(F("Sending email"));
  // change to recipient address
  client.println(F("To:  xxx@yormai.com"));
  // change to your address
  client.println(F("From: yyyyy@gmail.com"));
  client.println(F("Subject: Esp8266 email test\r\n"));
  client.println(F("This is from my ESP8266\n"));
  client.println(F("This is line 2 from my ESP8266"));
  client.println(F("This is line 3 from my ESP8266"));

  client.println(F("."));
  if (!eRcv()) return 0;
  Serial.println(F("Sending QUIT"));
  client.println(F("QUIT"));
  if (!eRcv()) return 0;
  client.stop();
  Serial.println(F("disconnected"));
  return 1;
}

byte eRcv()
{
  byte respCode;
  byte thisByte;
  int loopCount = 0;

  while (!client.available()) {
    delay(1);
    loopCount++;
    // if nothing received for 10 seconds, timeout
    if (loopCount > 10000) {
      client.stop();
      Serial.println(F("\r\nTimeout"));
      return 0;
    }
  }

  respCode = client.peek();
  while (client.available())
  {
    thisByte = client.read();
    Serial.write(thisByte);
  }

  if (respCode >= '4')
  {
    //  efail();
    return 0;
  }
  return 1;
}




Awesome, thanks, Andrew
User avatar
By ElectroInnovaciones
#40752
Erni wrote:Hi,
I have used this Arduino example on a Esp8266-01.
I made a few changes but it works as expected and sends mail without problems.

http://playground.arduino.cc/Code/Email?action=sourceblock&num=2

If you have trouble with this, I will try to find the sketch again, and post it here.


Hi Erni, my name is Carlos and im been trying to send and email with my Arduino Uno and the ESP81266 module, with SMTP2GO servers, but i have had not lucky, can you help me ????? :cry: :cry: :cry: :cry: my email is: electroinnovaciones@outlook.com thank !!!!!
User avatar
By theory
#40846 I'm getting multiple compile errors when I use this sketch for some reason. I'm very new to the esp8266 and Arduino world so I know I'm lacking some fundamental skills, but any help is appreciated.

I copied and pasted Erni's code and here's what I've received:

Code: Select allArduino: 1.6.7 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Serial, 115200, 4M (3M SPIFFS)"


C:\Users\Owner\Documents\Arduino\sketch_feb10a\sketch_feb10a.ino: In function 'void setup()':

sketch_feb10a:26: error: 'sendEmail' was not declared in this scope

   byte ret = sendEmail();

                        ^

C:\Users\Owner\Documents\Arduino\sketch_feb10a\sketch_feb10a.ino: In function 'byte sendEmail()':

sketch_feb10a:44: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

sketch_feb10a:48: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

sketch_feb10a:51: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

sketch_feb10a:55: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

sketch_feb10a:59: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

sketch_feb10a:63: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

sketch_feb10a:67: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

sketch_feb10a:70: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

sketch_feb10a:82: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

sketch_feb10a:85: error: 'eRcv' was not declared in this scope

   if (!eRcv()) return 0;

             ^

exit status 1
'sendEmail' was not declared in this scope