API / Minn\Mail / Composer

Composer final class

Minn\Mail\Composer · public/minn/src/Minn/Mail/Composer.php · 253 lines

A message as the reference's mailer writes it: the header block (Date, the address lines, Subject, Message-ID, X-Mailer, custom headers, MIME-Version), the MIME header for its type, and the body, multipart when it has an alternative, inline parts or attachments. Boundaries are "b1=_{id}" to "b3=_{id}"; a 7-bit-clean body declared 8bit goes out as 7bit us-ascii, and a body with a line past 998 characters as quoted-printable.

Used by 1

Constants and properties

privateICAL_METHODS = array ( 0 => 'REQUEST', 1 => 'PUBLISH', 2 => 'REPLY', 3 => 'ADD', 4 => 'CANCEL', 5 => 'REFRESH', 6 => 'COUNTER', 7 => 'DECLINECOUNTER', )

Public

staticbody(Minn\Mail\Draft $d, string $id): array#

The body and the encoding a single-part message declares.

@return array{body: string, encoding: string}
staticheaders(Minn\Mail\Draft $d, string $id, string $hostname, string $encoding): string#

The header block, MIME-Version and the MIME header included.

staticmimeHeaders(Minn\Mail\Draft $d, string $id, string $encoding): string#

The MIME header for the message's type: the content type (with its boundary) and the transfer encoding.

staticmailOnlyHeaders(Minn\Mail\Draft $d): string#

The To and Subject lines PHP's mail() takes as arguments, written after the headers in the sent copy.

staticaddressLine(Minn\Mail\Draft $d, string $name, array $list): string#

"Name: a, b" for a list of [address, name] pairs.

$listlist<array{0: string, 1: string}>
staticaddress(Minn\Mail\Draft $d, array $pair): string#

One address as a header writes it: the address alone, or the name (as a phrase) and the address in angle brackets.

$pairarray{0: string, 1: string}
staticsecure(string $text): string#

Header text with any line break taken out.

staticmessageId(string $given, string $id, string $hostname): string#

The message id given when it is well formed, else one made from the id and the host name.

Internals 11

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

privateencodingFor(Minn\Mail\Draft $d, string $text): array#
@return array{0: string, 1: string} the encoding and charset a body part declares
privatepartHead(Minn\Mail\Draft $d, string $boundary, string $charset, string $contentType, string $encoding): string#
privaterelated(Minn\Mail\Draft $d, string $outer, string $inner): string#
privatealternative(Minn\Mail\Draft $d, string $outer, string $inner): string#
privateend(Minn\Mail\Draft $d, string $boundary): string#
privatecalendar(Minn\Mail\Draft $d, string $boundary, string $after): string#

A text/calendar part when the message carries one, followed by $after; its method is the calendar's own (upper-cased) when it is a known one.

privatedate(string $given): string#

The date given when it reads as a moment already past, else now; either way as RFC 5322 writes it.

privateattachAll(Minn\Mail\Draft $d, string $disposition, string $boundary): string#

Every attachment of one disposition as parts of the boundary, then the boundary's end; an identical one, or a repeated inline id, goes once.

privateattachmentHead(Minn\Mail\Draft $d, array $a, string $boundary): string#
$aarray<int, mixed>
privateattachmentData(array $a): string#
$aarray<int, mixed>
privateextraLines(Minn\Mail\Draft $d): array#
@return list<string> X-Priority, X-Mailer, Disposition-Notification-To and the custom headers