PHPMailer - PHP Error


PHPMailer - PHP Error

PHP Fatal error:  Class 'Mail' not found in /.............../crons/Mail.php on line 2

知道为什么代码中没有提到它时它说"邮件"吗?这是我的PHP脚本:

<?php
    require("database.php");
    include_once("Mail.php");
    $query = $db->query("SELECT * FROM `emails` WHERE `sent`='0' LIMIT 50");
    if ($query->rowCount()>=1)
    {
        while($row = $query->fetch(PDO::FETCH_ASSOC))
        {
        $email = stripslashes($row['message']);
        //Create a new PHPMailer instance
        $mail = new PHPMailer();
        $mail->isSMTP();
        //Enable SMTP debugging
        // 0 = off (for production use)
        // 1 = client messages
        // 2 = client and server messages
        $mail->SMTPDebug = 2;
        //Ask for HTML-friendly debug output
        $mail->Debugoutput = 'html';
        //Set the hostname of the mail server
        $mail->Host = 'localhost';
        //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
        $mail->Port = 25;
        //Set the encryption system to use - ssl (deprecated) or tls
        $mail->SMTPSecure = 'tls';
        //Whether to use SMTP authentication
        $mail->SMTPAuth = true;
        //Username to use for SMTP authentication - use full email address for gmail
        $mail->Username = "help@pingrglobe.com";
        //Password to use for SMTP authentication
        $mail->Password = "ping123rglobe";
        //Set who the message is to be sent from
        $mail->setFrom('help@pingrglobe.com', 'PingrGlobe Support');
        //Set an alternative reply-to address
        $mail->addReplyTo('help@pingrglobe.com', 'PingrGlobe Support');
        //Set who the message is to be sent to
        $mail->addAddress($row['email'], 'John Doe');
        //Set the subject line
        $mail->Subject = $row['subject'];
        //Replace the plain text body with one created manually
        $mail->Body = $email;
        //send down here etc
所以基本上,我得到了这段代码,

我得到了上面代码所述的错误,它没有做任何事情。全新的PHPMailer下载,"邮件"甚至不是一个正在使用的类,我很困惑。

您可能需要邮件的前几行.php:

<?php
/**
 * PHPMailer - PHP email creation and transport class.
 * PHP Version 5.0.0
 * Version 5.2.7
 * @package PHPMailer
 * @link https://github.com/PHPMailer/PHPMailer/
 * @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
 * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
 * @author Brent R. Matzelle (original founder)
 * @copyright 2013 Marcus Bointon
 * @copyright 2010 - 2012 Jim Jagielski
 * @copyright 2004 - 2009 Andy Prevost
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @note This program is distributed in the hope that it will be useful - WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 */
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
    exit("Sorry, PHPMailer will only run on PHP version 5 or greater!'n");
}
/**
 * PHPMailer - PHP email creation and transport class.
 * PHP Version 5.0.0
 * @package PHPMailer
 * @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
 * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
 * @author Brent R. Matzelle (original founder)
 * @copyright 2013 Marcus Bointon
 * @copyright 2010 - 2012 Jim Jagielski
 * @copyright 2004 - 2009 Andy Prevost
 */
class PHPMailer
{
    /**
     * The PHPMailer Version number.
     * @type string
     */
    public $Version = '5.2.7';

请确保您的php.ini's include_path指向PEAR目录。如果您通过控制台安装了 PEAR,并且PEAR自动将其路径添加到 php.ini ,请记住,在您重新启动 Web 服务器后,添加的include_path将可用。

检查正确的大小写也很重要

include_once("mail.php") //without a capital M. 

请确保为 PHPmailer 创建正确的$mail对象。

$mail = (对象( new PHPmailer((;

请尝试此示例:

<?php
include_once('class.PHPmailer.php');

       $mailer = (object) new PHPmailer();                  
$your_Email ='abc@gmail.com';
//$mailer->AddBCC("");
$mailer->From = "no.reply@gmail.com";    
$mailer->FromName = "no.reply@gmail.com";  
$mailer->AddAddress($your_Email);
$mailer->Subject = "Thanks for contacting ...";
$mailer->Body= "";
$mailer->Body.="<br>";
$mailer->Body.= "  Thanks for contacting us .";
$mailer->Body.="<br>";
$mailer->Body.="<br><br><table>
               <tr><td align='left' >&nbsp;</td></tr>   
<tr><td align='left' style='color:#828282;font-size:10px;' >Note: For your privacy and protection, please do not forward this mail to anyone as it allows you to get 
automatically logged into your account. This is an automated email and please do not reply to this mail.</td></tr>
</table>";
//echo $mailer->Body;
                       //send mail as HTML
$mailer->IsHTML(true);
//set charset
$mailer->CharSet = "utf-8";
//set mailing method... mail, smtp or sendmail
$mailer->Mailer = "sendmail";
$mailer->Send();
/*if ($mailer->Send())
{ 
  echo"TRUE SENT MAIL";
}
else
{
echo "FAIL";
}*/
}
/*     SEND MAIL         */
?>