MIME is really just a collective name for a series of RFC (request for
comment) documents that add additional functionality to the basic email specification such as character
encoding, attachments, and more. Zend_Mime provides the MIME functionality in Zend_Mail and can also be
used as a component on its own.
All our code in Listing 9.1 really does is to define a few headers followed by the body and then sends the
email and in table 9.2 we compare the role that those headers and body have to a physical letter.
Table 9.2 Comparing a physical letter with an email
Physical Mail Email
Envelope Recipient and address Headers Fields using the field name: field body syntax that
include information about the email such as
sender, recipient, and more.
Letter The written contents Body The text of the message being sent
Licensed to Menshu You
Zend Framework in Action (Ch010) Manning Publications Co. 4
Just as you may want to add a picture of your kids in a physical letter, so can you add images as
attachments with Zend_Mail by using:
$mail->createAttachment($pictureOfKids);
Having dropped in that important picture, you then write a note on the envelope with the officious looking
warning "Photographs - Do NOT Bend" and with Zend_Mail we could theoretically do the same thing by
adding additional headers:
$mail->addHeader('PhotoWarningNote', 'Photographs - Do NOT Bend');
Of course, just as the note on the envelope will likely be ignored and your picture will arrive complete
with crease line, so too will that header be ignored as PhotoWarningNote is not a header recognised by any
mail user agents!
Adding additional headers with PHP??™s mail() function is something a developer needs to take care with as
if you are not careful it is possible for a malicious user to add headers such as further recipients.
Pages:
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250