我正在使用PEAR Mail.php库在PHP5中将一个表单处理脚本从一个站点迁移到另一个站点。 该脚本粘贴在此消息的底部。一切似乎都很好。即使在脚本中,我也没有得到任何PHP错误:
error_reporting(E_ERROR | E_WARNING | E_PARSE);
但浏览器结果指向PEAR返回的PEAR错误状态:
"An email error has occurred..."
这是脚本中的结果:
if (PEAR::isError($mail2)) {
这就是说,我不知道如何找到有关此PEAR错误的更多详细信息。是否有办法通过PEAR打开某种显式错误消息?
有关以下代码的任何建议?
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Relies on PEAR Mail module!
require_once "Mail.php";
if (isset($_REQUEST['pdfName']) && isset($_REQUEST['pdfEmail'])) {
$name = $_REQUEST['pdfName'];
$email = $_REQUEST['pdfEmail'];
$file = $_REQUEST['pdfFile'];
$host = 'smtpout.secureserver.net';
$user = 'ot@domain.com';
$pass = 'password';
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $user,
'password' => $pass));
$to = "info@domain.com";
$Bcc = "dan@domain.com";
$recipients = $to.", ".$Bcc;
$from = "info@domain.com";
$subject = "Document request on company.com";
$body = "Hello Sales Team,
Name: $name
Email: $email
Requested the file: http://en.domain.com/docs/$file";
$headers = array ('From' => $from,
'To' => $to,
'Bcc' => $Bcc,
'Subject' => $subject);
$mail = $smtp->send($recipients, $headers, $body);
$to = $email;
$from = "info@domain.com";
$subject = "company Your document is here";
$body = "Hello $name,
The document you requested one http://www.domain.com can be found here:
http://en.domain.com/docs/$file
Enjoy the information.
If you have questions, do not hesitate to contact us.
E-Mail: info@domain.com
Tel: +1 (000) 606 4000 (US office)
Kind regards
The company Team
www.domain.com
The information contained in this email is intended only for the use of the person or entity to whom it is addressed and may contain information that is confidential and maybe legally privileged and exempt from disclosure under applicable laws. If you read this message and are not the addressee, you are notified that use, dissemination, distribution or reproduction of this message is legally prohibited. If you have received this message in error, please notify us immediately and return the original message to us.";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$mail2 = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail2)) {
//echo("<p>" . $mail2->getMessage() . "</p>");
echo("<tr>
<td colspan='2' style='margin:10px 0 20px 10px;'>
<div style='margin:10px 0 2px 5px;color:#01578C;'>An email error has occurred.</div>
<div style='margin:0 0 20px 5px;'>Please provide a valid email address so we can send you a link to the requested document.</div></td>
</tr>
<tr>
<td align='left' valign='top' style='width: 350px;'><span style='padding-left:5px' >Please submit a new request.</span></td>
<td style='padding:2px 5px;'><div style='height:109px;'> </div></td>
</tr>");
} else {
echo("<tr>
<td colspan='2' style='margin:10px 0 20px 10px;'>
<div style='margin:10px 0 2px 5px;color:#01578C;'>Your data were sent successfully.</div>
<div style='margin:0 0 20px 5px;'>A link to the requested document was sent to the email address you provided.</div></td>
</tr>
<tr>
<td align='left' valign='top' style='width: 350px;'><span style='padding-left:5px' >Enjoy the information.</span>
<P>
<br>
<A HREF=\"javascript:history.go(-2)\">Click here to go back to browsing company.com.
</td>
<td style='padding:2px 5px;'><img align='left' alt='' src='/docdown/index-files/whitepaper.jpg'/></td>
</tr>
");
}
} else {
echo("<tr>
<td colspan='2' style='margin:10px 0 20px 10px;'>
<div style='margin:10px 0 2px 5px;color:#01578C;'>
An error has occurred.</div>
<div style='margin:0 0 20px 5px;'>Please provide a valid email address so we can send you a link to the requested document.</div></td>
</tr>
<tr>
<td align='left' valign='top' style='width: 350px;'><span style='padding-left:5px' >Please submit a <A HREF=\"javascript:history.go(-1)\"> new request on the previous page.</a></span></td>
<td style='padding:2px 5px;'><div style='height:109px;'> </div></td>
</tr>");
}
?>
答案 0 :(得分:1)
你已经把它弄好了,注释掉了。
echo("<p>" . $mail2->getMessage() . "</p>");
答案 1 :(得分:-1)
好的 - 找到它 - 这段代码很好地解决了这个问题:
// Pear Mail error messaging
if ($emailerror = PEAR::isError($mail)) {
echo("<p><br><p><br>" . $mail->getMessage() . "</p>"); exit;
}