Files
glastree/vendor/directorytree/imapengine/src/Support/MimeMessage.php
T

27 lines
671 B
PHP
Raw Normal View History

2026-05-26 08:14:29 +02:00
<?php
namespace DirectoryTree\ImapEngine\Support;
use DirectoryTree\ImapEngine\BodyStructurePart;
class MimeMessage
{
/**
* Build a minimal MIME message from body structure metadata and raw content.
*/
public static function make(BodyStructurePart $part, string $content): string
{
$headers = ["Content-Type: {$part->contentType()}"];
if ($charset = $part->charset()) {
$headers[0] .= "; charset=\"{$charset}\"";
}
if ($encoding = $part->encoding()) {
$headers[] = "Content-Transfer-Encoding: {$encoding}";
}
return implode("\r\n", $headers)."\r\n\r\n".$content;
}
}