How to send an HTML Mail using Pear:Mail.

Example to send an HTML main in PHP using Pear:Mail.

<?php 
require_once "Mail.php"; 
require_once "Mail/mime.php";

$from 		= "your-email@host.com";
$to 		= "your-email@host.com"; 
$username 	= "your-email@host.com";
$password 	= "yourPassword"; 
$host 		= "mail.host.com"; 

$subject 	="Simple Email Test from SMTP"; 
$text = 'This is a text message.';// Text version of the email
$html = '<html><body><p>HTML message</p></body></html>';// HTML version of the email

$crlf = "\r\n";

$headers = array (	'From' => $from,
					'To' => $to,
					'Subject' => $subject);

// Creating the Mime message
$mime = new Mail_mime($crlf);

// Setting the body of the email
$mime->setTXTBody($text);
$mime->setHTMLBody($html);

$body = $mime->get();
$headers = $mime->headers($headers);


$smtp = Mail::factory('smtp',
	array ('host' => $host,
	'auth' => true,
	'username' => $username,
	'password' => $password));
	$mail = $smtp->send($to, $headers, $body);
	
	if (PEAR::isError($mail)) {
		echo("<p>" . $mail->getMessage() . "</p>");
	} else {
	echo("<p>Message successfully sent!</p>");
	}

 ?>