PHP Mailer is_a():已弃用。请使用instanceof运算符

时间:2016-05-08 12:22:17

标签: php

执行PHP Mailer代码时出现上述错误。我不禁想出原因。 PHP版本是5.2。在我的免费网络托管服务器000webhost.com。

错误截图显示在那里;

error

require 'PHPMailer-master/PHPMailerAutoload.php';

date_default_timezone_set('Asia/Colombo'); //this function sets the default timezone used by all data/time functions in the script
                                           //Solution for the error - It is not safe to rely on the system's timezone settings.
ini_set ( 'max_execution_time', 1200); //Solution for the error - set_time_limit() has been disabled for security reasons 

$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'thisistestemail16@gmail.com';                 // SMTP username
$mail->Password = 'testemail123';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;                                    // TCP port to connect to

$mail->setFrom('thisistestemail16@gmail.com', 'Raveen Chandra');
$mail->addAddress('raveen749@gmail.com', 'Chairman');     // Add a recipient
//$mail->addAddress('ellen@example.com');               // Name is optional
//$mail->addReplyTo('info@example.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');

$mail->addAttachment('uploads/3.JPG');         // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

1 个答案:

答案 0 :(得分:0)

/*
public function smtpClose()
    {
        //if (is_a($this->smtp, 'SMTP')) {
        $o = 'SMTP';
        if($this->smtp instanceof $o) {
            if ($this->smtp->connected()) {
                $this->smtp->quit();
                $this->smtp->close();
            }
        }
    }
*/