This document provides in-depth information for developers who want to monitor, debug, or extend the behavior of ReadyMail using low-level processing callbacks and custom commands.
The SMTPStatus struct provides detailed information about the current state of the SMTP process. You can access it via:
SMTPClient::status() — to poll the current statusSMTPResponseCallback — to receive real-time updates during sendingvoid smtpStatusCallback(SMTPStatus status) {
if (status.progress.available) {
ReadyMail.printf("State: %d, Uploading file %s, %d%% completed\n",
status.state,
status.progress.filename.c_str(),
status.progress.value);
} else {
ReadyMail.printf("State: %d, %s\n", status.state, status.text.c_str());
}
if (status.isComplete) {
if (status.errorCode < 0) {
ReadyMail.printf("Process Error: %d\n", status.errorCode);
} else {
ReadyMail.printf("Server Status: %d\n", status.statusCode);
}
}
}
You can send raw SMTP commands using SMTPClient::sendCommand() and receive responses via:
SMTPCustomComandCallback — for real-time responseSMTPClient::commandResponse() — to retrieve the last responseSMTPCommandResponse Structurecommand — The command sent (e.g. "VRFY")text — Server response textstatusCode — SMTP status code (e.g. 250, 550)errorCode — Negative value indicates errorThe IMAPStatus struct provides real-time updates and final results of IMAP operations. You can access it via:
IMAPClient::status() — to pollIMAPResponseCallback — for real-time updatesvoid imapStatusCallback(IMAPStatus status) {
ReadyMail.printf("State: %d, %s\n", status.state, status.text.c_str());
}
The IMAPDataCallback provides access to both envelope (headers) and body (attachments, inline content) during fetch operations.
auto dataCallback = [](IMAPCallbackData data) {
if (data.event() == imap_data_event_fetch_envelope) {
for (int i = 0; i < data.headerCount(); i++) {
Serial.printf("%s: %s\n", data.getHeader(i).first.c_str(), data.getHeader(i).second.c_str());
}
}
};
During body fetch (imap_data_event_fetch_body), you can access:
fileInfo().filename, mime, charset, transferEncoding, fileSizefileChunk().data, index, size, isCompletefileProgress().value — percentage completeUse IMAPClient::sendCommand() to send raw IMAP commands (e.g. STORE, COPY, MOVE, CREATE, DELETE) and receive responses via:
IMAPCustomComandCallbackIMAPClient::commandResponse()IMAPCommandResponse Structurecommand — The command senttext — Server response (untagged or full)isComplete — True when response is completeerrorCode — Negative value indicates errorFor examples of advanced usage, see the Command.ino, OTA.ino, and AutoClient.ino examples in the examples/ folder.