protected static function HTMLMailMime::parseDecoded in HTML Mail 8
Same name and namespace in other branches
- 8.3 src/Utility/HtmlMailMime.php \Drupal\htmlmail\Utility\HtmlMailMime::parseDecoded()
Recursively copies message parts into a MailMIME object.
Copies the MIME parts from an object returned by Mail_mimeDecode->decode() into a MailMIME object, including subparts of any 'multipart' parts.
Parameters
\Drupal\htmlmail\Utility\HTMLMailMime $parsed: The target MailMIME object.
object $decoded: The object returned by Mail_mimeDecode->decode() whose MIME parts are being copied.
string $parent_subtype: The content-type subtype of the parent multipart MIME part. This should be either 'mixed', 'related', or 'alternative'. Defaults to an empty string, signifying the root of the MIME tree.
1 call to HTMLMailMime::parseDecoded()
- HTMLMailMime::parse in src/
Utility/ HTMLMailMime.php - Parse a complete message and return a MailMIME object.
File
- src/
Utility/ HTMLMailMime.php, line 528 - Provides the MailMIME class for creating MIME-formatted email messages.
Class
- HTMLMailMime
- Class HTMLMailMime.
Namespace
Drupal\htmlmail\UtilityCode
protected static function parseDecoded(HTMLMailMime &$parsed, &$decoded, $parent_subtype = '') {
if ($decoded->ctype_primary == 'multipart') {
if (!empty($decoded->parts)) {
foreach (array_keys($decoded->parts) as $key) {
self::parseDecoded($parsed, $decoded->parts[$key], $decoded->ctype_secondary);
}
}
return;
}
if (empty($decoded->body)) {
return;
}
switch ($decoded->ctype_primary) {
case 'text':
if ($parent_subtype == '' || $parent_subtype == 'alternative' || $parent_subtype == 'related') {
if ($decoded->ctype_secondary == 'plain') {
$parsed
->setTxtBody($decoded->body);
return;
}
elseif ($decoded->ctype_secondary == 'html') {
$parsed
->setHtmlBody($decoded->body);
return;
}
}
break;
case 'image':
if ($parent_subtype == 'related') {
$cid = isset($decoded->headers['content-id']) ? $decoded->headers['content-id'] : NULL;
return;
}
break;
default:
$type = $decoded->ctype_primary . '/' . $decoded->ctype_secondary;
$name = isset($decoded->d_parameters['name']) ? $decoded->d_parameters['name'] : (isset($decoded->d_parameters['filename']) ? $decoded->d_parameters['filename'] : '');
if (!empty($name) && !empty($cid)) {
$parsed
->addHtmlImage($decoded->body, $type, $name, FALSE, $cid);
return;
}
$parsed
->addAttachment($decoded->body, $type, $name, FALSE);
}
}