getMethod('buildMime'); $buildMime->setAccessible(true); $plain = $buildMime->invoke( $sender, 'from@example.org', 'From Name', ['to@example.org'], [], [], "All Saint's café", '
Hello
', null, [] ); if (!is_string($plain) || strpos($plain, 'Content-Type: text/html; charset=UTF-8') === false) { fwrite(STDERR, "Plain MIME rendering missing HTML content-type header\n"); exit(1); } if (strpos($plain, "Subject: All Saint's café") !== false) { fwrite(STDERR, "Subject header should not contain raw UTF-8/punctuation text\n"); exit(1); } if (strpos($plain, 'Subject: =?UTF-8?B?QWxsIFNhaW50J3MgY2Fmw6k=?=') === false) { fwrite(STDERR, "Subject header missing expected RFC 2047 encoding\n"); exit(1); } if (strpos($plain, 'From: =?UTF-8?B?RnJvbSBOYW1l?=Hello
', null, [[ 'filename' => 'sample.jpg', 'mime_type' => 'image/jpeg', 'content_bytes' => $bytes, ]] ); if (!is_string($mime) || strpos($mime, 'multipart/mixed') === false) { fwrite(STDERR, "Multipart MIME expected for attachment payload\n"); exit(1); } if (strpos($mime, 'Content-Type: image/jpeg; name="sample.jpg"') === false) { fwrite(STDERR, "Attachment MIME part missing expected content-type/filename\n"); exit(1); } if (strpos($mime, base64_encode(substr($bytes, 0, 24))) === false) { fwrite(STDERR, "Attachment bytes do not appear to be base64-encoded into MIME payload\n"); exit(1); } echo "BasicSmtpSender MIME regression test passed\n";