- Forums
- PHP
- Pear Mail.php Show Error When Email Form Sends It Fails
This Page Contains information about Pear Mail.php Show Error When Email Form Sends It Fails By wallpaperama in category PHP with 3 Replies. [1245], Last Updated: Sat May 18, 2024
wallpaperama
Sun Jan 25, 2009
3 Comments
1029 Visits
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