xreef / EMailSender

Arduino, esp32, Esp8266 EMailSender with Arduino IDE, simple library to send email via smtp with attachments.
https://www.mischianti.org/category/my-libraries/emailsender-send-email-with-attachments/
MIT License
75 stars 28 forks source link

Time out #10

Closed gratefulfrog closed 3 years ago

gratefulfrog commented 3 years ago

Hi, Although this seemed to work for a few mails, Now all I get is :

Sending status: 
0
1
SMTP Response TIMEOUT!

Any help would be great! Thanks for all the work!

xreef commented 3 years ago

Hi gratefulfrog, can you enable the debug mode and send me the result. Please send me the provider also, and the code can be usefully. Bye Renzo

gratefulfrog commented 3 years ago

Thanks, but how do I enable debug? ?

On Mon, 23 Nov 2020, 21:52 Renzo Mischianti, notifications@github.com wrote:

Hi gratefulfrog, can you enable the debug mode and send me the result. Please send me the provider also, and the code can be usefully. Bye Renzo

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xreef/EMailSender/issues/10#issuecomment-732419441, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOUDF62VT6ZZ5TNAGQDMVLSRLDRFANCNFSM4T76S5YQ .

gratefulfrog commented 3 years ago

Ok! I found it! Here's the output! By the way, is this code using your account somehow on gmail? I see you get welcomed??

I put *** to remove my credentials.

Any help would be great, thanks! Buonasera!

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Connecting to **********************
......
Connection: ESTABLISHED
Got IP address: 192.168.1.112
ONLY ONE RECIPIENTInsecure client:0
220 smtp.gmail.com ESMTP t7sm21981239wrp.26 - gsmtp

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

AUTH LOGIN:
334 VXNlcm5hbWU6

Encoding
frogshutters@gmail.com
22
ZnJvZ3NodXR0ZXJzQGdtYWlsLmNvbQ==
Encoding
frogshutters@gmail.com
22
334 UGFzc3dvcmQ6

Encoding
*****************
9
SWhodGZzIy4u
Encoding
*********************
9
235 2.7.0 Accepted

MAIL FROM: <frogshutters@gmail.com>
250 2.1.0 OK t7sm21981239wrp.26 - gsmtp

RCPT TO: <gratefulfrog@gmail.com>
250 2.1.5 OK t7sm21981239wrp.26 - gsmtp

DATA:
354  Go ahead t7sm21981239wrp.26 - gsmtp

Message end
Sending status: 
0
1
SMTP Response TIMEOUT!
xreef commented 3 years ago

Hi gratefulfrog, post your code, I made test with esp8266 and esp32 and works correctly. Bye Renzo

gratefulfrog commented 3 years ago

It is just the example code, I have removed my credentials: Thanks for your help! Bob

/*
 * EMailSender library for Arduino, esp8266 and esp32
 * Simple esp32 Gmail send example
 *
 * https://www.mischianti.org/category/my-libraries/emailsender-send-email-with-attachments/
 *
 */

#include "Arduino.h"
#include <EMailSender.h>
#include <WiFi.h>

const char* ssid = "<YOUR-SSID>";
const char* password = "<YOUR-PASSWD>";

uint8_t connection_state = 0;
uint16_t reconnect_interval = 10000;

EMailSender emailSend("account_login@gmail.com", "<YOUR-GMAIL-PASSWD>");

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);
    }

    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(ssid, password);
    if(!connection_state)  // if not connected to WIFI
        Awaits();          // constantly trying to connect

    EMailSender::EMailMessage message;
    message.subject = "Soggetto";
    message.message = "Ciao come stai<br>io bene.<br>www.mischianti.org";

    EMailSender::Response resp = emailSend.send("receive_email@gmail.com", message);

    Serial.println("Sending status: ");

    Serial.println(resp.status);
    Serial.println(resp.code);
    Serial.println(resp.desc);
}

void loop()
{

}
xreef commented 3 years ago

Hi, I tested your code and work properly,

I think you must check your environment:

If you have some information that I can check write here.

Bye Renzo

gratefulfrog commented 3 years ago

I don't know what to say.

I can use other libraries to send gmail from that account, very similar to yours.. I have no idea why it fails...

On Tue, 24 Nov 2020 at 17:31, Renzo Mischianti notifications@github.com wrote:

Hi, I tested your code and work properly,

I think you must check your environment:

  • permission of gmail account
  • if your network is filtered
  • if you use strange character It's very strange behavior.

If you have some information that I can check write here.

Bye Renzo

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xreef/EMailSender/issues/10#issuecomment-733092947, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOUDF3ZDZEJZ4OLCOSJKALSRPNWHANCNFSM4T76S5YQ .

xreef commented 3 years ago

What kind of device do you use? Bye Renzo

gratefulfrog commented 3 years ago

I am using an ESP-32 Dev Kit C V4 https://www.az-delivery.de/en/products/esp-32-dev-kit-c-v4?_pos=1&_sid=238bd5070&_ss=r .

Since I couldn't get it to work anymore with your library, I tried this one https://github.com/mobizt/ESP32-Mail-Client and it works perfectly, no timeouts ever...

I don't have the time to dive deeper to see what the differences are between your library and the other one...

Thanks so much for trying to help !!! Ciao, Bob

On Wed, 25 Nov 2020 at 07:42, Renzo Mischianti notifications@github.com wrote:

What kind of device do you use? Bye Renzo

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xreef/EMailSender/issues/10#issuecomment-733502167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOUDF7AIDBRCTAG2MU4TLDSRSRNZANCNFSM4T76S5YQ .

xreef commented 3 years ago

Thanks for your patience, but I can't replicate the issue so I must close It. Bye Renzo