AbstractAbstractconnectOpens a connection to an SMTP server and authenticates.
Handles the full SMTP handshake: greeting, EHLO, optional STARTTLS upgrade, and AUTH LOGIN authentication.
Server address, port, TLS/STARTTLS setting, and credentials
An opaque session handle for subsequent operations
AbstractsendSends an email message.
Constructs a properly formatted RFC 2822 message with MIME support and sends it via the SMTP protocol. Handles multipart messages when both text and HTML bodies are provided.
Session handle from connect()
The email message to send
Send result with Message-ID and per-recipient acceptance status
AbstractdisconnectCloses the SMTP connection.
Always call this when done, preferably in a finally block.
Session handle from connect()
Built-in tool for SMTP email sending.
Provides high-level SMTP operations for composing and sending email. Handles TCP/TLS connections, STARTTLS upgrades, SMTP protocol details, and RFC 2822 message formatting internally.
Permission model: Connectors declare which SMTP hosts they need access to. Connections to undeclared hosts are rejected.
Example