如何修复[处理此指令时发生错误]?

时间:2016-10-30 13:05:06

标签: php

我正在尝试使用php imap()从收件箱中获取电子邮件。在localhost函数中工作正常但在我们基于bluehost的专用服务器上它显示以下错误

[an error occurred while processing this directive]

Php代码

$imap = @imap_open("{mail.******.com:143/novalidate-cert}", "a****i@*****.com", "******");

if(isset($imap)){
                $message_count = @imap_num_msg($imap);
                $array_mail = array();
                if($message_count > 0){
                    for ($m = 1; $m <= $message_count; ++$m){
                        //$header = @imap_header($imap, $m);
                        $header = @imap_rfc822_parse_headers(imap_fetchheader($imap, $m));
                        $email[$m]['from'] = $header->from[0]->mailbox.'@'.$header->from[0]->host;
                        //$email[$m]['fromaddress'] = $header->from[0]->personal;
                        //$email[$m]['to'] = $header->to[0]->mailbox;
                        //$email[$m]['cc'] = $header->cc[0]->mailbox;
                        //$email[$m]['subject'] = $header->subject;
                        //$email[$m]['message_id'] = $header->message_id;
                        //$email[$m]['date'] = $header->udate;

                        //$from = $email[$m]['fromaddress'];
                        $from_email = $email[$m]['from'];
                        $array_mail[] = $from_email;
                        if(isset($header->cc)){
                            $hedCC = $header->cc;
                            foreach($hedCC as $s){
                                echo $s->mailbox.'@'.$s->host.'<br />';
                                //$array_mail[] = $s->mailbox.'@'.$s->host;
                            }
                        }

                        if(isset($header->to)){
                            $hedTO = $header->to;
                            foreach($hedTO as $t){
                                echo $t->mailbox.'@'.$t->host.'<br />';
                                //$array_mail[] = $t->mailbox.'@'.$t->host;
                            }
                        }
                    }
                    $i = 0;
                    if (!empty($array_mail)) {
                        $insertCount = 0;
                        foreach($array_mail as $m_){
                            // INSERT HERE
                            //echo $m_.'<br />';
                            $isExistWithID  = $this->isExistWithID($user_id,$m_);
                            $email_err      = $this->isValidEmail($m_);
                            $isValid = 0;
                            if($email_err == false){
                                $isValid = 1;
                            }
                            if($isExistWithID==0 && $isValid==0){
                                $insert = $this->pdoConnection->prepare("
                                    INSERT INTO ws_email (
                                        u_id,
                                        we_email, 
                                        date_added
                                    ) 
                                    VALUES(
                                        :u_id, 
                                        :we_email, 
                                        :date_added
                                    )
                                    ");
                                $insert->bindParam(':u_id', $u_id);
                                $insert->bindParam(':we_email', $we_email);
                                $insert->bindParam(':date_added', $date_added);

                                // Insert Data
                                $u_id           = $_SESSION['USERID'];
                                $we_email       = $m_;
                                $date_added     =  date("Y-m-d H:i:s");
                                if($insert->execute()){
                                    $insertCount++;
                                }
                            }
                            $i++;

                        }// end foreach
                        $response['success']        = $insertCount . ' Email address(s) fetched successfully.';
                    } 
                    //echo $i; 
                    //
                }else{
                    $response['error']      = 'No record found';
                }
            }else{
                $response['error']      = 'IMAP does not connect'; 
            }
        /************ END NEW 29 SEP *************/
        echo json_encode($response, JSON_PRETTY_PRINT);

任何人都可以指导我在哪里可以解决的问题。我想要感激。谢谢。

EDITED 我向主机提供商添加了票证。以下是评论,

This error is because of a the FCGI timeout. This can be fixed by changing to suphp. You can change the php type in the whm to suphp on the Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration page. I suggest to closely watch the website with that to suphp as it makes the server more vulnerable to scripts running unchecked.

0 个答案:

没有答案