After instantiating the Mail_Mime class you
call the headers() method and pass in this array, as is demonstrated in this example:
// Include the Mail and Mime_Mail Packages
include('Mail.php');
include('Mail/mime.php');
// Recipient Name and E-mail Address
$name = "Jason Gilmore";
$recipient = "jason@example.com";
// Sender Address
$from = "bram@example.com";
// CC Address
$cc = "marketing@example.com";
// Message Subject
$subject = "Thank you for your inquiry";
CHAPTER 16 ?– NETWORKING 415
// E-mail Body
$txt = <<
This is the e-mail message.
txt;
// Identify the Relevant Mail Headers
$headers['From'] = $from;
$headers['Cc'] = $subject;
$headers['Subject'] = $subject;
// Instantiate Mail_mime Class
$mimemail = new Mail_mime();
// Set HTML Message
$mimemail->setTxtBody($html);
// Build Message
$message = $mimemail->get();
// Prepare the Headers
$mailheaders = $mimemail->headers($headers);
// Create New Instance of Mail Class
$email =& Mail::factory('mail');
// Send the E-mail!
$email->send($recipient, $mailheaders, $message) or die("Can't send
message!");
?>
Sending an HTML-Formatted E-mail
Although many consider HTML-formatted e-mail to rank among the Internet??™s greatest
annoyances, how to send it is a question that comes up repeatedly. Therefore, it seems
prudent to offer an example and hope that no innocent recipients are harmed as a result.
Pages:
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496