echo $mail->getMessage();

today i was asked twice why when you try to send an smtp email through php and pear Mail.php function it fails, but it doesn't display what the error is. well, if you are using the function to send email through smtp with PEAR Mail.php then all you have to do is echo this: Pear Mail.php doesn't show error messages !!

this is a peace of example code i have

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if ($emailerror = PEAR::isError($mail)) {

echo("<p>" . $mail->getMessage() . "</p>"); exit;
}



so as you can see, its easy to find out what the error is giving out and show it on the broswer