11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

www.it-ebooks.infoCHAPTER 16 • NETWORKINGTaking Advantage of PEAR: Mail and Mail_MimeWhile it’s possible to use the mail() function to perform more complex operations such as sending tomultiple recipients, annoying users with HTML-formatted e-mail, or including attachments, doing socan be a tedious and error-prone process. However, the Mail (http://pear.php.<strong>net</strong>/package/Mail) andMail_Mime (http://pear.php.<strong>net</strong>/package/Mail_Mime) PEAR packages make such tasks a breeze. Thesepackages work in conjunction with one another: Mail_Mime creates the message, and Mail sends it. Thissection introduces both packages.Installing Mail and Mail_MimeTo take advantage of Mail and Mail_Mime, you’ll first need to install both packages. To do so, invoke PEARand pass along the following arguments:%>pear install Mail Mail_MimeExecute this command and you’ll see output similar to the following:Starting to download Mail-1.2.0.tgz (23,214 bytes)......done: 23,214 bytesdownloading Mail_Mime-1.7.0.tgz ...Starting to download Mail_Mime-1.7.0.tgz (31,175 bytes)...done: 31,175 bytesinstall ok: channel://pear.php.<strong>net</strong>/Mail_Mime-1.7.0install ok: channel://pear.php.<strong>net</strong>/Mail-1.2.0Sending an E-mail with Multiple RecipientsUsing Mime and Mime_Mail to send an e-mail to multiple recipients requires that you identify theappropriate headers in an array. After instantiating the Mail_Mime class, you call the headers() methodand pass in this array, as demonstrated in this example:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!