azjezz/psl
PSL is a modern, well-typed standard library for PHP 8.4+, inspired by HHVM’s HSL. It offers safer, predictable APIs for async, collections, networking, I/O, crypto, terminal UI, and robust data validation—replacing brittle built-ins with consistent alternatives.
The SMTP component implements an RFC 5321 SMTP client with connection pooling, TLS, authentication, and support for modern SMTP extensions. It integrates with the Message and MIME components for complete email sending.
The Transport handles the full SMTP lifecycle: connection, EHLO, TLS, authentication, message transmission, and connection reuse. Pass an Envelope (derived from message headers) and a MessageInterface to send.
@example('protocols/smtp-basic.php')
Five authentication mechanisms are supported. Pass any AuthenticatorInterface as the second argument to Transport.
@example('protocols/smtp-auth.php')
TransportConfiguration controls connection-level settings: host, port, security mode, pipelining, chunking, and TCP/TLS options. All settings are immutable with fluent with*() builders.
@example('protocols/smtp-config.php')
SendConfiguration controls per-send MAIL FROM extension parameters: DSN notifications, REQUIRETLS, message priority, delivery deadlines, and deferred delivery.
@example('protocols/smtp-send-config.php')
By default, the transport throws on the first rejected recipient. Enable allowPartialSuccess to deliver to accepted recipients and report failures via DeliveryReport.
@example('protocols/smtp-partial.php')
The transport is fully async-capable. Use Async\concurrently to send multiple messages in parallel with automatic connection pooling. Use cancellation tokens for timeouts.
@example('protocols/smtp-async.php')
Connection implements Network\StreamInterface and speaks raw SMTP commands. Use it for direct protocol interaction or to build custom transports.
@example('protocols/smtp-connection.php')
The transport automatically negotiates these extensions when the server advertises them:
| Extension | RFC | Description |
|---|---|---|
| PIPELINING | RFC 2920 | Send multiple commands before reading replies |
| CHUNKING | RFC 3030 | BDAT transfer without dot-stuffing |
| BINARYMIME | RFC 3030 | Binary content without transfer encoding |
| 8BITMIME | RFC 6152 | 8-bit MIME transport |
| SMTPUTF8 | RFC 6531 | Internationalized email addresses |
| STARTTLS | RFC 3207 | TLS upgrade on plaintext connections |
| DSN | RFC 3461 | Delivery status notifications |
| REQUIRETLS | RFC 8689 | End-to-end TLS enforcement |
| MT-PRIORITY | RFC 6710 | Message priority levels |
| DELIVERBY | RFC 2852 | Delivery deadline specification |
| FUTURERELEASE | RFC 4865 | Deferred delivery |
| SIZE | RFC 1870 | Server maximum message size |
The transport validates all SMTP commands for CRLF and null byte injection attacks. Malicious input in addresses, hostnames, or DSN parameters throws PossibleAttackException before reaching the wire.
See src/Psl/SMTP/ for the full API.
How can I help you explore Laravel packages today?