mini\Mail\MailboxInterface
abstract
interface
Documentation
Mailbox Interface
Represents an RFC 5322 mailbox: a display name with an addr-spec (email address). Implements Stringable to allow seamless use in string contexts.
Terminology (RFC 5322)
- mailbox = display name + addr-spec (e.g.,
Frode Børli <frode@ennerd.com>) - addr-spec = local-part "@" domain (e.g.,
frode@ennerd.com) - display name = human-readable name (e.g.,
Frode Børli)
Usage
// Parse from string
$mailbox = Mailbox::fromString('Frode Børli <frode@ennerd.com>');
$mailbox->getAddrSpec(); // 'frode@ennerd.com'
$mailbox->getDisplayName(); // 'Frode Børli'
// Build programmatically
$mailbox = new Mailbox('frode@ennerd.com');
$mailbox = $mailbox->withDisplayName('Frode Børli');
// Use in string context
echo $mailbox; // 'Frode Børli <frode@ennerd.com>'
// Email-only (no display name)
$mailbox = new Mailbox('noreply@example.com');
echo $mailbox; // 'noreply@example.com'
Format
The string representation follows RFC 5322:
- With display name:
Display Name <local@domain> - Without display name:
local@domain
Special characters in the display name are quoted as needed.
Inheritance
Implements:
Stringable
Methods (5)
Get the addr-spec (email address)
Get the display name
Return instance with the specified addr-spec
Return instance with the specified display name
Get the RFC 5322 formatted mailbox string