25#ifndef PROTOCORE_SMTP_H
26#define PROTOCORE_SMTP_H
60typedef int (*
SmtpSendFn)(
void *ctx,
const uint8_t *data,
size_t len);
61typedef int (*
SmtpRecvFn)(
void *ctx, uint8_t *buf,
size_t cap);
SmtpResult smtp_send(const SmtpConfig *cfg, const SmtpMessage *msg)
Blocking one-shot send over the real transport (pc_client, plus TLS when cfg->tls)....
SmtpResult smtp_run(const SmtpConfig *cfg, const SmtpMessage *msg, SmtpSendFn send, SmtpRecvFn recv, SmtpStartTlsFn starttls, void *ctx)
Drive the full SMTP exchange over send / recv. Pure - no lwIP or TLS - so it is host-testable with a ...
SmtpSecurity
How the connection is secured.
@ SMTP_STARTTLS
connect in the clear, then upgrade in band (submission, port 587).
@ SMTP_TLS
implicit TLS from the first byte (SMTPS, port 465).
@ SMTP_PLAIN
no TLS at all (port 25) - credentials and body travel in the clear.
int(* SmtpSendFn)(void *ctx, const uint8_t *data, size_t len)
Transport seam for smtp_run(): the engine sends and receives raw bytes only through these,...
SmtpResult
Result of an SMTP send. 0 is success; every failure is a distinct negative code.
@ SMTP_ERR_IO
a send/recv failed or the reply timed out
@ SMTP_ERR_ARG
a required field (host / from / to) was null or empty
@ SMTP_ERR_AUTH
AUTH was rejected (bad user/password)
@ SMTP_ERR_OVERFLOW
a command line or the message exceeded its fixed buffer
@ SMTP_ERR_TLS
the TLS handshake failed (SMTPS)
@ SMTP_ERR_PROTOCOL
the server returned an unexpected reply code
@ SMTP_ERR_NO_STARTTLS
STARTTLS was required but the server did not advertise it.
@ SMTP_ERR_CONNECT
could not open the transport (DNS / connect)
int(* SmtpRecvFn)(void *ctx, uint8_t *buf, size_t cap)
bool(* SmtpStartTlsFn)(void *ctx)
Upgrade the live connection to TLS in place (RFC 3207), after the server's 220.
Server address + credentials for one send. Addresses are bare (no angle brackets).
const char * user
AUTH LOGIN username (null or empty => skip AUTH)
SmtpSecurity security
how to secure the connection
const char * pass
AUTH LOGIN password.
const char * from
envelope sender + From: header address
uint16_t port
25 (plain) / 587 (STARTTLS) / 465 (implicit TLS)
const char * host
server hostname (also the TLS SNI name)
const char * helo
EHLO domain to announce (null => "esp32")
const char * body
plain-text UTF-8 body; LF or CRLF line ends, dot-stuffed for you
const char * to
single recipient address (envelope + To: header)
const char * subject
Subject: header (null => empty)