ReadyMail

⚙️ Advanced Usage — ReadyMail

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.


📚 Table of Contents


📤 SMTP Processing Information

The SMTPStatus struct provides detailed information about the current state of the SMTP process. You can access it via:

🔄 Callback Example

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

🧪 SMTP Custom Command Processing Information

You can send raw SMTP commands using SMTPClient::sendCommand() and receive responses via:

📦 SMTPCommandResponse Structure


📥 IMAP Processing Information

The IMAPStatus struct provides real-time updates and final results of IMAP operations. You can access it via:

🔄 Callback Example

void imapStatusCallback(IMAPStatus status) {
  ReadyMail.printf("State: %d, %s\n", status.state, status.text.c_str());
}

✉️ IMAP Envelope and Body Data

The IMAPDataCallback provides access to both envelope (headers) and body (attachments, inline content) during fetch operations.

📬 Envelope Example

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

📎 File Info

During body fetch (imap_data_event_fetch_body), you can access:


🧩 IMAP Custom Command Processing Information

Use IMAPClient::sendCommand() to send raw IMAP commands (e.g. STORE, COPY, MOVE, CREATE, DELETE) and receive responses via:

📦 IMAPCommandResponse Structure


For examples of advanced usage, see the Command.ino, OTA.ino, and AutoClient.ino examples in the examples/ folder.