Skip to content

wificlientsecure fails to connect with smtp2go, but works with gmail #3932

Closed
@kapyaar

Description

@kapyaar

Please fill the info fields, it helps to get you faster support ;)

if you have a stack dump decode it:
https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/stack_dump.rst

for better debug messages:
https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/debugging.rst

----------------------------- Remove above -----------------------------

Basic Infos

Hardware

Hardware: ESP-12
Core Version: 2.4.0-rc2

Description

I am working on the ESP8266 gmail sender (http://www.instructables.com/id/ESP8266-GMail-Sender/) to send email using WiFiClientSecure. I can get it to work with gmail, but fail to get even connect to the server with mail.smtp2go.com.

Settings in IDE

Module: ?nodeMCU 0.9?
Flash Size: ?4MB/1MB?
CPU Frequency: ?80Mhz?
Flash Mode: ?DOUT?
Flash Frequency: ?40Mhz?
Upload Using: ?SERIAL?
Reset Method: ?ck / nodemcu?

Sketch

#include <Gsender.h>
#include "ESP8266WiFi.h"


#pragma region Globals
const char* ssid = "MyWiFi"; // WIFI network name
const char* password = "Password"; // WIFI network password
uint8_t connection_state = 0; // Connected to WIFI or not
uint16_t reconnect_interval = 10000; // If not connected wait time to try again
#pragma endregion Globals

uint8_t WiFiConnect(const char* nSSID = nullptr, const char* nPassword = nullptr)
{
  static uint16_t attempt = 0;
  Serial.print("Connecting to ");
  if (nSSID) {
    WiFi.begin(nSSID, nPassword);
    Serial.println(nSSID);
  } else {
    WiFi.begin(ssid, password);
    Serial.println(ssid);
  }

  uint8_t i = 0;
  while (WiFi.status() != WL_CONNECTED && i++ < 50)
  {
    delay(200);
    Serial.print(".");
  }
  ++attempt;
  Serial.println("");
  if (i == 51) {
    Serial.print("Connection: TIMEOUT on attempt: ");
    Serial.println(attempt);
    if (attempt % 2 == 0)
      Serial.println("Check if access point available or SSID and Password\r\n");
    return false;
  }
  Serial.println("Connection: ESTABLISHED");
  Serial.print("Got IP address: ");
  Serial.println(WiFi.localIP());
  return true;
}

void Awaits()
{
  uint32_t ts = millis();
  while (!connection_state)
  {
    delay(50);
    if (millis() > (ts + reconnect_interval) && !connection_state) {
      connection_state = WiFiConnect();
      ts = millis();
    }
  }
}

void setup()
{
  Serial.begin(115200);
  connection_state = WiFiConnect();
  if (!connection_state) // if not connected to WIFI
    Awaits(); // constantly trying to connect

  Gsender *gsender = Gsender::Instance(); // Getting pointer to class instance
  const char* EMAILBASE64_LOGIN = "base64_encoded_loginemail";
  const char* EMAILBASE64_PASSWORD = "base64_encoded_password";


  const char* FROM = "[email protected]";

  String subject = "Subject is optional";
  if (gsender->Subject(subject)->Send("[email protected]", "Alerts are working now")) {


    Serial.println("Message send.");
  } else {
    Serial.print("Error sending message: ");
    Serial.println(gsender->getError());
  }
}

void loop() {}

Debug Messages

With gmail I get the following:

Connecting to :smtp.gmail.com:465
please start sntp first !
220 smtp.gmail.com ESMTP n3sm3479813qte.14 - gsmtp

HELO localhost:
250 smtp.gmail.com at your service

AUTH LOGIN:
334 VXNlcm5hbWU6

EMAILBASE64_LOGIN: d*********************************9t
334 UGFzc3dvcmQ6

EMAILBASE64_PASSWORD:b************E=
235 2.7.0 Accepted

MAIL FROM: <w**********[email protected]>
250 2.1.0 OK n3sm3479813qte.14 - gsmtp

RCPT TO: <a*******[email protected]>
250 2.1.5 OK n3sm3479813qte.14 - gsmtp
DATA:
354  Go ahead n3sm3479813qte.14 - gsmtp
250 2.0.0 OK 1512667183 n3sm3479813qte.14 - gsmtp
221 2.0.0 closing connection n3sm3479813qte.14 - gsmtp
============================================

with mail.smtp2go.com, I tried different port numbers and get teh following.
Connecting to :mail.smtp2go.com:2525
please start sntp first !
ssl->need_bytes=8301 > 6859

Connecting to :mail.smtp2go.com:465
please start sntp first !
Error: connection lost

Connecting to :mail.smtp2go.com:25
please start sntp first !
ssl->need_bytes=8301 > 6859

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions