Email32 more debug (#21010)

* more debug on esp32 mail

* Update xdrv_01_2_webserver_esp32_mail.ino
This commit is contained in:
gemu 2024-03-22 08:09:16 +01:00 committed by GitHub
parent 3c70e63af8
commit aad917d060
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -194,12 +194,11 @@ uint16_t SendMail(char *buffer) {
#ifdef DEBUG_EMAIL_PORT #ifdef DEBUG_EMAIL_PORT
smtp->debug(true); smtp->debug(true);
smtp->callback(smtpCallback);
#else #else
smtp->debug(false); smtp->debug(false);
#endif #endif
// smtp->callback(smtpCallback);
SMTP_Message message; SMTP_Message message;
email_mptr = &message; email_mptr = &message;
message.clearRecipients(); message.clearRecipients();
@ -390,14 +389,19 @@ void send_message_txt(char *txt) {
/* Callback function to get the Email sending status */ /* Callback function to get the Email sending status */
void smtpCallback(SMTP_Status status) { void smtpCallback(SMTP_Status status) {
/* Print the current status */ /* Print the current status */
Serial.println(status.info()); //Serial.println(status.info());
AddLog(LOG_LEVEL_INFO, PSTR("MAI: %s"),status.info());
/* Print the sending result */ /* Print the sending result */
if (status.success()) { if (status.success()) {
Serial.println("----------------"); //Serial.println("----------------");
Serial.printf("Message sent success: %d\n", status.completedCount()); //Serial.printf("Message sent success: %d\n", status.completedCount());
Serial.printf("Message sent failled: %d\n", status.failedCount()); AddLog(LOG_LEVEL_INFO, PSTR("MAI: Message sent success: %d"),status.completedCount());
Serial.println("----------------\n");
//Serial.printf("Message sent failled: %d\n", status.failedCount());
AddLog(LOG_LEVEL_INFO, PSTR("MAI: Message sent failed: %d"),status.failedCount());
//Serial.println("----------------\n");
struct tm dt; struct tm dt;
for (size_t i = 0; i < smtp->sendingResult.size(); i++) { for (size_t i = 0; i < smtp->sendingResult.size(); i++) {
@ -405,13 +409,20 @@ void smtpCallback(SMTP_Status status) {
SMTP_Result result = smtp->sendingResult.getItem(i); SMTP_Result result = smtp->sendingResult.getItem(i);
localtime_r((time_t*)&result.timestamp, &dt); localtime_r((time_t*)&result.timestamp, &dt);
Serial.printf("Message No: %d\n", i + 1); //Serial.printf("Message No: %d\n", i + 1);
Serial.printf("Status: %s\n", result.completed ? "success" : "failed"); AddLog(LOG_LEVEL_INFO, PSTR("MAI: Message No: %d"),i + 1);
Serial.printf("Date/Time: %d/%d/%d %d:%d:%d\n", dt.tm_year + 1900, dt.tm_mon + 1, dt.tm_mday, dt.tm_hour, dt.tm_min, dt.tm_sec);
Serial.printf("Recipient: %s\n", result.recipients); //Serial.printf("Status: %s\n", result.completed ? "success" : "failed");
Serial.printf("Subject: %s\n", result.subject); AddLog(LOG_LEVEL_INFO, PSTR("MAI: Status: %s"),result.completed ? "success" : "failed");
//Serial.printf("Date/Time: %d/%d/%d %d:%d:%d\n", dt.tm_year + 1900, dt.tm_mon + 1, dt.tm_mday, dt.tm_hour, dt.tm_min, dt.tm_sec);
AddLog(LOG_LEVEL_INFO, PSTR("MAI: Date/Time: %d/%d/%d %d:%d:%d"), dt.tm_year + 1900, dt.tm_mon + 1, dt.tm_mday, dt.tm_hour, dt.tm_min, dt.tm_sec);
//Serial.printf("Recipient: %s\n", result.recipients);
AddLog(LOG_LEVEL_INFO, PSTR("MAI: Recipient: %s"),result.recipients.c_str());
//Serial.printf("Subject: %s\n", result.subject);
AddLog(LOG_LEVEL_INFO, PSTR("MAI: Subject: %s"),result.subject.c_str());
} }
Serial.println("----------------\n"); //Serial.println("----------------\n");
} }
} }