rgb192
asked on
trap and record smtp reply
$mail->Send();
echo "Mail was sent.</p>\n";
$email_wait=0;
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
$email_wait=2;
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
$email_wait=3;
}
http://www.greenend.org.uk/rjk/tech/smtpreplies.html
is all the smtp replys
but the phpmailer try catch only catches two types of exceptions
I only get this trapped
echo $e->errorMessage(); //Pretty error messages from PHPMailer
and not this
echo $e->getMessage(); //Boring error messages from anything else!
but I want all types of errors to be logged
For "catch" to work you have to use "try" and it's not shown in your example code. I think I would fix that first, then create the SSCCE so we have something we can test with. You can use var_dump() to print out the contents of the exception object.
ASKER
using phpmailer try/catch
how can I vardump and trap this error
how can I vardump and trap this error
try {
$mail->IsHTML(true);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = $smtpdebug; // enables SMTP debug information (for testing)
$mail->SMTPAuth = $smtpauth; // enable SMTP authentication
$mail->SMTPSecure = $smtpsecure; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = $port; // set the SMTP port for the GMAIL server
$mail->Username = "username"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->From = $mail->Username;
$mail->FromName = "my name";
$mail->AddAddress($email);
$mail->Body='body';
$mail->Subject='subject';
$mail->Send();
echo "Mail was sent.</p>\n";
$email_wait=0;
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
$email_wait=2;
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
$email_wait=3;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
Depending on your server set up you may not have access to it with php.