Title: pear mail.php show error when form fails
Description: pear mailphp show error when form fails PHP
Tags: pear, mailphp, show, error, when, form, fails
Info: This Post Has Been Viewed 666 Times SinceSun Jan 25, 2009 9:31 pm Author wallpaperama With 3 Replies #7025

pear mail.php show error when form fails

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

Comments (3)
View Top Comments
Leave Your Comments...
#1
travis:
2 years ago
#91513
travis Sun Jan 25, 2009 9:33 pm
yeah i was the one who asked you that, thanks for answering my questions. it works i was able to find what my problem was, i had the name and email address backwords, i was putting the name where the email goes and the email where the name goes. thanks wallpaperama.
#2
meker:
2 years ago
#91522
meker Sun Jan 25, 2009 10:55 pm
i also have this problem how can you help do you have pm?
#3
lyris:
2 years ago
#91628
lyris Mon Jan 26, 2009 6:32 pm
i was able to install it with your tutorial, thanks for posting it here, now i can start with my own wallpaper website too. i m sure im gonna come back here agaain - lol!
Share
| More