Esp8266 sendemail

can anyone tell me why this doesn’`t work it compiles and uploads fine. in the serial monitor it says it connected to wifi and blink. if i unplug the nodemcu it will display device disconnected, but it never sends an email. it should send an email as soon as it connects correct???
here is the code:
// put your main code here, to run repeatedly:
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = " removed but correct in sketch ";

void emailOnButtonPress()
{
// *** WARNING: You are limited to send ONLY ONE E-MAIL PER MINUTE! ***

// Let’s send an e-mail when you press the button
// connected to digital pin 2 on your Arduino

int isButtonPressed = !digitalRead(2); // Invert state, since button is “Active LOW”

if (isButtonPressed) // You can write any condition to trigger e-mail sending
{
BLYNK_LOG(“Button is pressed.”); // This can be seen in the Serial Monitor
Blynk.email(“removed but correct in sketch t”, “Subject: Button Logger”, “You just pushed the button…”);

}
}

void setup()
{
Serial.begin(9600);
Blynk.begin(auth, “2WIREXXX”, “removed but correct in sketch”);

while (Blynk.connect() == false) {
// Wait until connected
}

// Send e-mail when your hardware gets connected to Blynk Server
// Just put the recepient’s “e-mail address”, “Subject” and the “message body”
Blynk.email(“removed but correct in sketch t”, “Subject”, “My Blynk project is online.”);

// Setting the button
pinMode(2, INPUT_PULLUP);
// Attach pin 2 interrupt to our handler
attachInterrupt(digitalPinToInterrupt(2), emailOnButtonPress, CHANGE);
}

void loop()
{
Blynk.run();

}

Do you have the Email widget in your project?

Many ESP users get confused with the pins, sure it is pin 2?

Does Serial Monitor show the log text?

Which version of the library and app are you using?

Android or iOS?

i am using the android platform. yes i am sure it is pin2 , the serial monitor shows it connecting to my wifi and the blynk ascII logo. as mentioned it knows when i unplug it, by a little message device disconnected so it does have some communication it just doesn’t send an email

1 Like