我正在使用 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>");
}
?>