Skip to main content

SMTP Email Helpers

smtp_send(config) → (success, error)

Send an email via SMTP and wait for confirmation (10s timeout).

Config table fields:

  • server (string, required) - SMTP server hostname
  • port (number, optional) - SMTP port (default based on TLS mode: starttls→587, tls→465, none→25)
  • tls (string, optional) - "starttls" (default), "tls", or "none"
  • username (string, optional) - SMTP username
  • password (string, optional) - SMTP password
  • from (string, required) - Sender email address
  • to (string or array, required) - Recipient email address(es)
  • subject (string, required) - Email subject
  • text (string, optional) - Plain text body
  • html (string, optional) - HTML body

At least one of text or html must be provided. Returns: success (boolean), error (string|nil).

smtp_send_async(config) → boolean

Fire-and-forget variant (10s timeout in background). Same config as smtp_send. Returns true if queued, false if validation failed.