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

Send email to provider other than Google #11

Closed Tech500 closed 3 years ago

Tech500 commented 3 years ago

Please add an example for using another email account other than Google. Emailing and SMS text work great with dedicated Gmail account; thank you for the library code.

Had trouble understanding blog post: https://www.mischianti.org/2020/06/16/send-email-with-attachments-emailsender-v2-x-library-esp32-and-esp8266-part-2/

EMailSender(const char email_login, const char email_password, const char email_from, const char name_from, const char* smtp_server, uint16_t smtp_port);

When compiling; this line produces error: "expected unqualified-id before 'const'"

Maybe something I am overlooking; have not been successful in resolving this issue.

xreef commented 3 years ago

Hi Tech500, I think you must post the code you can try to execute to debug It.

But you can find the sendgrid provider management in this example https://github.com/xreef/EMailSender/blob/master/examples/EMailSenderArduinoMegaUIPSendgridTest/EMailSenderArduinoMegaUIPSendgridTest.ino

Bye Renzo

Tech500 commented 3 years ago

How do I correct?

250 Identification error (501 Syntactically invalid HELO argument(s))

My code:

`/*

include "Arduino.h"

include

include

const char ssid = "ssid"; const char password = "networkpassword";

uint8_t connection_state = 0; uint16_t reconnect_interval = 10000;

/*

Email settings detail for mw.net
http://mw.net/techsupport.shtml

*/

EMailSender emailSend("", "", "", "", "mail.mw.net", 465); //Will this wotk; SSL/TLS port?

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 = "ESP8266 email test";
message.message = "This is a test email";

EMailSender::Response resp = emailSend.send("<email_address>", message);

Serial.println("Sending status: ");

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

}

void loop() {

}

/*

Compiles with no errors.

Serial Monitor output:

Connection: ESTABLISHED Got IP address: 10.0.0.140 Sending status: 0 250 Identification error (501 Syntactically invalid HELO argument(s))

*/ `

xreef commented 3 years ago

Hi Tech500, I think your provider don't like the custom string on HELO command, you must check what kinf of string It expect and set It with this command.

emailSend.setPublicIpDescriptor("");

you can have this problem also if you don't use the provider line.

Bye RM