Site icon Renzo Mischianti

Email sender with variables

Greetings! I'm not too familiar with c family programming languages, so i'm certainly messed up something. I'm need to use this library with variables from configuration. So i'm do that. Of course not working. I'm fixed the most errors but something wrong... The error message is:

Compilation error: no matching function for call to 'EMailSender::send(const char [18], int, EMailSender::EMailMessage&)'
The definition is:
#include
#include
#include
#include
#include
#include
#include
#include
//#include
#include
#include
#include "variables.h"

ESP32Time rtc(0);
WiFiUDP wifiUdp;
NTP ntp(wifiUdp);

EMailSender emailSend(smtpuser.c_str(), smtppass.c_str(), smtpfrom.c_str(), smtpserver.c_str(), strtol(smtpport.c_str(),NULL,0));

#include "ok_html.h"
#include "manager_html.h"
#include "failed_html.h"
#include "edit_html.h"
#include "FS.h"
#include "SPIFFS.h"
#include "functions.h"
#include "Webserver.h"
The variables (from another file, see the definiton) :
String smtpserver ="mail.example.com"; //smtp server address
String smtpuser ="user@example.com"; //smtp user address
String smtppass ="password"; //smtp password
String smtpport ="578";
String recipientaddress ="";
String smtpfrom = "user@example.com";
String messagebody = "";
String host = "SZTCont";
bool enableTLS = false; //tls enabled
And the email send function:
void sendmessage(){
if (wifiOK && smtpserver.length() >0 && smtpuser.length() >0 && smtppass.length() > 0 && smtpport.length() > 0 && recipientaddress.length() > 0 && smtpfrom.length() > 0){

EMailSender::EMailMessage message;
message.subject = "[" + host + "]: " + "test";
message.message = "ez a szöveg a levélben";

const byte maxCount = 4;
const byte maxStringLength = 40;
char arrayofemail[maxCount][maxStringLength] = {"mail@example.com"};
String str = recipientaddress;
int StringCount = 0;
// Az emailok átalakítása
while (str.length() > 0)
{
int index = str.indexOf(',');
if (index == -1) // No space found
{

strlcpy(arrayofemail[StringCount++], str.c_str(), maxStringLength);
break;
}
else
{
String str2 = str.substring(0, index);
strlcpy(arrayofemail[StringCount++], str2.c_str(), maxStringLength);
str = str.substring(index+1);
}
}
const char *recips = arrayofemail[0];
EMailSender::Response resp = emailSend.send("valaki@valahol.hu", 3, message);
Serial.println("Sending status: ");
Serial.println(resp.status);
Serial.println(resp.code);
Serial.println(resp.desc);

} else {
Serial.println("A rendszer nincs wifihez kapcsolódva, levéküldés nem lehetséges");
}
}
Need to known, i'm like the clean coding. i'm separate the functions in a file, and call from it. Maybe this is the problem, but If it's possible I would use it this formula. If need other info please ask.
Exit mobile version