API / Minn\Mail / AddressRules

AddressRules final class

Minn\Mail\AddressRules · public/minn/src/Minn/Mail/AddressRules.php · 91 lines

Email addresses: the checks a mailer can apply (PHP's filter, the RFC 5322 grammar with comments, quoted local parts and domain literals, the HTML5 form rule), parsing an address list, and the domain of an address in ASCII.

Uses 1
Used by 1

Constants and properties

privateHTML5 = '/^[a-zA-Z0-9.!#$%&\'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD'

Public

staticvalid(string $address, string $pattern): bool#

Whether the address passes the named check ("php", "pcre", "pcre8", "html5", "noregex").

staticparseList(string $list, string $charset): array#

The addresses in a comma-separated list, as the reference's simple parser reads one: split at every comma, quoted or not, each entry with its display name (encoded words decoded into $charset); entries that are not valid addresses are left out.

@return list<array{name: string, address: string}>
staticasciiDomain(string $address, string $charset): string#

The address with its domain in ASCII (IDNA), the domain read from $charset first; unchanged when it cannot be.

staticquoted(string $text): string#

The text as an RFC 822 quoted string when it holds a character that needs one.

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privaterfc5322(string $address): bool#

RFC 5322 addr-spec with comments and folding white space, a quoted local part or a domain literal; local part 64, label 63 characters.