1

我收到这些错误:

PHP致命错误:main()[function.require]:打开失败需要'/usr/share/pear/Mail.php'(include_path ='。:/var/www/vhosts/xxx.net/httpdocs/protected/modules /rbam/models:/var/www/vhosts/xxx.net/httpdocs/protected/extensions/translations/components:/var/www/vhosts/xxx.net/httpdocs/protected/extensions/runactions/components:/var/ www/vhosts/xxx.net/httpdocs/protected/components:/var/www/vhosts/xxx.net/httpdocs/protected/models:/usr/share/pear:') 在 /var/www/vhosts/xxx 中。第 70 行的 net/httpdocs/protected/components/MailComponent.php

首先, include 语句不在 my 的第 70 行MailComponent.php,它在第 3 行(但MailComponent.php正好有 69 行,所以这可能只是 PHP 报告错误的方式中的一个错误)

require_once '/usr/share/pear/Mail.php'; 

该文件/usr/share/pear/Mail.php就在那里,/usr/share/pear/Mail.php它属于root,但它对每个人都有读取权限;正如您/usr/share/pear在包含路径中看到的那样。而且,这曾经一直有效,直到最近我还没有碰过它。

那么可能是什么问题?!?!?

编辑:我认为这与包含文件所在的文件夹不在httpdocs folder.

(我也对此感到困惑main(),我在任何地方都没有这样的方法;我使用的是 Yii,它确实有几个main()方法在这里和那里(只是 grepped)尽管据报道错误出现在我的代码中,据称在我MailComponent.php的 include_once 所在的位置)。

<?php

require_once '/usr/share/pear/Mail.php'; // PEAR Mail
require_once '/usr/share/pear/Mail/mime.php'; // PEAR Mail_mime

class MailComponent extends CApplicationComponent {

    public $defaultHeaders=array();
    public $debugUsers=false;
    public $debugAdmins=false;
    public $debugEmail='matteosistisette@gmail.com';
    public $backend='mail';

    public function sendMail($address, $subject, $body, $headers=array(), $isadmin=false) {

        $actualheaders=array_merge($this->defaultHeaders, $headers);
        $actualheaders['Subject']=$subject;

        $mail = new Mail_mime(array(
            "text_charset" => "utf-8",
            "html_charset" => "utf-8",
            "eol" => "\n"
        ));

        $mail->setTxtBody($body);

        if (($isadmin && $this->debugAdmins) || (!$isadmin && $this->debugUsers)) {
            $address=str_replace('@','_AT_',$address)." <".$this->debugEmail.">";
            //$address=$this->debugEmail;
        }
        $actualheaders['To']=$address;
        $headersencoded=array();
        foreach ($actualheaders as $header=>$value) {
            $headersencoded[$header]=$mail->encodeHeader($header, $value, "utf-8", "quoted-printable");
        }
        //$to=$mail->encodeHeader('To',$address,"utf-8", "quoted-printable");
        $to=$headersencoded['To'];
        $msg=@$mail->get();
        $actualheaders=$mail->headers($headersencoded);
        @$factory=& Mail::factory($this->backend);
        @$ret=$factory->send($to,$actualheaders,$msg);
        if ($ret instanceof PEAR_Error) Yii::log('ERROR SENDING MAIL TO '.$to, 'error');
        return $ret;     
    }

    public function notifyAdmins($role, $area, $subjectcode, $bodycode, $params=array()) {
        $admins=Yii::app()->authManager->getUsers($role);
        $users=array();
        foreach ($admins as $userid) {
            $user=User::model()->findByPk($userid);
            if ($user===null) continue;
            if ($user->current_area_id!=$area->id) continue;
            if ($user->email===null || ($email=trim($user->email))=='') continue;
            $lang=$user->preferredLanguage;
            $params['{CHANNEL_NAME}']=I::tattr($area->partialRoot, 'menu.home', $lang);
            $params['{USER}']=$user->getActualDisplayName();
            $subject=I::t($subjectcode,$lang,$params);
            $body=I::t($bodycode,$lang,$params);
            $this->sendMail($email, $subject, $body, array(), true);
        }
    }

}

?>
4

1 回答 1

0

您确定正在加载文件“MailComponent.php”的正确版本吗?如果,如您所说,这个文件有 69 行,并且错误出现在第 70 行,我首先会怀疑该错误是指其他 MailComponent.php 文件。

于 2013-03-31T21:37:52.197 回答