<?php
class Mail {
         var $pathCommon = "";
         var $mailHost = "bj-cas.bj.ton.corp";
var $mailFrom = "[email protected]";
var $mail = NULL;
var $logHost = NULL;
var $logUser = NULL;
var $logPass = NULL;
var $logDB = NULL;

function Mail($path=false) {
$this->pathCommon = "http://".$_SERVER['SERVER_NAME']."/_common5/class"; $this->pathCommon = ($path==false) ?$this->pathCommon :$path;
/*  
@include($this->pathCommon."/../connection/config.php"); $this->setDataBase($dbbitintrahost, $dbbitintrauname, $dbbitintrapass, $dbbitintraname);
 */
}

function setDataBase($host='', $user='', $pass='', $db='') {
$this->logHost = ($host=='') ?$this->logHost :$host;
$this->logUser = ($host=='') ?$this->logUser :$user;
$this->logPass = ($host=='') ?$this->logPass :$pass;
$this->logDB = ($host=='') ?$this->logDB :$db;
}

function phpMailer() {
require_once($this->pathCommon."/class/mail/phpmailer/phpmailer.php");
require_once($this->pathCommon."/class/mail/phpmailer/BIT.php"); // or die ("Failed opening file: error was '$php_errormsg'");
$this->mail = new BIT();
$this->mail->Host = $this->mailHost;
$this->mail->From = $this->mailFrom;
return $this->mail;
}

function phpPOPMail() {

}


function sendMail($varsubj, $varmsg, $varfrom='', $varto, $varcc, $varbcc, $varatt='', $varsystem=''){
return $this->mail->BitSendMail($varsubj, $varmsg, $varfrom, $varto, $varcc, $varbcc, $varatt);
}
} $Mail = new Mail();
 $To = "[email protected]";
 $Cc = "[email protected]";
 $Mail->sendMail("ACTION",'',rtrim($To,","),rtrim($Cc,","),$Text);
?>我执行 mail.php页面时
调用函数的时候报错。。
Warning: Missing argument 6 for Mail::sendMail(), called in E:\Papyerus\copy-Papyrus\Web\_common5\class\Mail.php on line 51 and defined in E:\Papyerus\copy-Papyrus\Web\_common5\class\Mail.php on line 43Fatal error: Call to a member function BitSendMail() on a non-object in E:\Papyerus\copy-Papyrus\Web\_common5\class\Mail.php on line 44请问是什么原因..

解决方案 »

  1.   

     $Mail->sendMail("ACTION",'',rtrim($To,","),rtrim($Cc,","),$Text);
    这里少参数了。$Mail->sendMail("ACTION",'','',rtrim($To,","),rtrim($Cc,","),$Text);
      

  2.   


    还是报错..
    Fatal error: Call to a member function BitSendMail() on a non-object in E:\Papyerus\copy-Papyrus\Web\_common5\class\Mail.php on line 64???
      

  3.   

     var $mail = NULL;
    类初始化时没有对$mail变量赋值,所以会报这个错误。
      

  4.   

    function phpMailer() {
            require_once($this->pathCommon."/class/mail/phpmailer/phpmailer.php");
            require_once($this->pathCommon."/class/mail/phpmailer/BIT.php");    // or die ("Failed opening file: error was '$php_errormsg'");
            $this->mail = new BIT();
            $this->mail->Host = $this->mailHost;
            $this->mail->From = $this->mailFrom;
            return $this->mail;
        }
    红色部分放在外面去,你phpMailer没调用,$this->mail=new BIT()没执行,
    你在执行
    function sendMail($varsubj, $varmsg, $varfrom='', $varto, $varcc, $varbcc, $varatt='', $varsystem=''){
        return $this->mail->BitSendMail($varsubj, $varmsg, $varfrom, $varto, $varcc, $varbcc, $varatt);
        }
    的时候就会报对一个非对象调用一个成员方法的错误,或者你先调用一下phpMailer,在调用sendmail
      

  5.   


     $Mail1 = new Mail();
     $Mail1->mail->phpMailer(); //我先调用这个类...
     $To = "[email protected]";
     $Cc = "[email protected]";
     $Mail1->sendMail("ACTION",'','',rtrim($To,","),rtrim($Cc,","),$Text);但程序还是报错 ,,
    好像 $Mail1 = new Mail();  这句话没有用的样...
      

  6.   

    $Mail1 = new Mail();        //这样初始化 好像没有〉。。
     $Mail1->mail->phpMailer(); //我先调用这个函数...
     $To = "[email protected]";
     $Cc = "[email protected]";
     $Mail1->sendMail("ACTION",'','',rtrim($To,","),rtrim($Cc,","),$Text);
    var $mail = NULL;这句我 注释 拉...
    但程序还是报错 ,,
    好像 $Mail1 = new Mail(); 这句话没有用的样...
     
      

  7.   

     $Mail1->mail->phpMailer(); 
    改成$Mail->phpMailer