All those familiar with PHP's own mail function will immediately appreciate the way
Zend_Mail encapsulates the mail composition in a much more pleasing interface.
Listing 9.1 A simple Zend_Mail example
require_once 'Zend/Mail.php';
$mail = new Zend_Mail();
$mail->setFrom('welcome@greatnewsite.com', 'Support');
$mail->addTo('bert@bertsblog.com.au', 'Bert');
$mail->setSubject('An Invite to a great new site!');
$mail->setBodyText('Hi Bert, Here is an invitation to a great new website.');
$mail->send();
Now that we're looking at the composition of our email the first thing worth mentioning is that the email
produced by listing 9.1 is simple enough that it sits comfortably within the specification for email, otherwise
known as RFC 2822. The specifications for email are handled by the official internet body; the Internet
Engineering Task Force (IETF) and it is worth being a little familiar with some of this information as you will
see reference to it elsewhere. For example the manual currently states that one of the validation classes
"Zend_Validate_EmailAddress will match any valid email address according to RFC 2822".
Unfortunately RFC 2822 is a fairly limited specification and had Bert wanted to send an invite to his
friends in non-English speaking countries he would have had problems if it wasn't for the Multipurpose
Internet Mail Extensions (MIME).
Pages:
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249