So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Rajeesh
#84488 Hi all,

I am very new to ESP8266 and following this tutorial ... ifier.html

From this I am trying to get the unread email count from google. My code looks like

Code: Select all#include <WiFiClientSecure.h>   // Include the HTTPS library
#include <ESP8266WiFi.h>        // Include the Wi-Fi library

const char* host = "";
const char* url = "/mail/feed/atom"; 
const int httpsPort = 443; 

const char* ssid     = "BSNL";
const char* password = "PASSWORD123";         

void setup() {

  WiFi.begin(ssid, password);             // Connect to the network
  Serial.print("Connecting to ");
  Serial.print(ssid); Serial.println(" ...");

  int i = 0;
  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    Serial.print(++i); Serial.print(' ');

  Serial.println("Connection established!"); 
  Serial.print("IP address:\t");


void loop(){
   int unread = getUnread();

int getUnread() {   
  WiFiClientSecure client;  //connection
  Serial.printf("Connecting to %s:%d ... \r\n", host, httpsPort);
  if (!client.connect(host, httpsPort)) {   // Connect to the Gmail server, on port 443
    Serial.println("Connection failed");    // If the connection fails, stop and return
    return -1;

Didn't completed the function getUnread(). But as of now, always showing "connection failed" and returning -1.

Hardware : NodeMCU Amica (Has an ESP8266 Wifi Module)

IDE : Arduino latest version 1.8.10
Can anyone help ?