怀疑邮件错误



我正在使用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;'>&nbsp;</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>
&nbsp;<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;'>&nbsp;</div></td>    
</tr>");    
}    
?>    

就在这里,注释掉了。

echo("<p>" . $mail2->getMessage() . "</p>");

OK -找到了-这段代码做得很好:

 // Pear Mail error messaging
 if ($emailerror = PEAR::isError($mail)) {
 echo("<p><br><p><br>" . $mail->getMessage() . "</p>"); exit;
 }

最新更新