Prev | Current Page 259 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

There are a few points to mention however, the first being that the we??™ve not done
anything about the body_formatted field of our support table.
When we entered the body information with the web form it was put through the text to HTML markup
filter Markdown. In this case however the body of the email could be plain text or HTML or both, which is
referred to as multipart. If we enter an HTML or multipart email body directly into the body field it is going to
be a mess so in listing 9.12 we will check for that and reduce the body down to just the plain text content.
Listing 9.12: Reducting a multipart email down to its plain text component
$part = $message;
while ($part->isMultipart()) { A
$part = $message->getPart(1); B
}
if (strtok($part->contentType, ';') == 'text/plain') { C
$plainTextContent = $part->getContent(); D
}
A This loops as long as the Content-Type header of $part contains the text multipart/
B Reassigning the first part of the multipart message to the $part variable
C The first part is usually plain text but we??™ll do a check anyway
D Assigning the plain text content to a variable
In theory we could also insert any HTML part into the body_formatted field of our support table, however,
we??™d then need to do some careful filtering of the data and even after doing so we??™d then have to deal with all
the varieties of HTML markup from the various email clients.


Pages:
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
wentik.otiset.pl kebab Wczasy nad morzem kamerzysta chelm torpado