PHPMailer说该类不存在,但确实存在 [英] PHPMailer says the class doesn't exists, but it does

查看:70
本文介绍了PHPMailer说该类不存在,但确实存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要爆炸了!我已按照步骤一步一步(如下图所示)进行操作,但它仍然对我不起作用!

I am about to explode! I have followed this step, step by step (as the picture below shows) and it still doesn't work for me!

require_once 'configurations/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;

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

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'user@example.com';                 // SMTP username
$mail->Password = 'secret';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User');     // 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('/var/tmp/file.tar.gz');         // 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';
}

请注意,我已经从GitHub复制并粘贴了代码,并且更改了用户名或密码!如果上面的代码有效,我将不会收到Uncaught Error: Class 'PHPMailer' not found in ...的致命错误.

Please note that I have copied and pasted the code from GitHub and not changed the username nor the password! If the code above works, I wouldn't get the fatal error of Uncaught Error: Class 'PHPMailer' not found in ....

我已经完全按照我在其他项目中的图片和上面的代码(当然,做了一些小的更改)中的方式完成了此操作,而在这些项目上我完全没有问题!

I have done this exactly as it is in the picture and in the code above (with some minor changes, of course) on my other projects and I have no problems at all with this on those projects!

我错过了什么?怎么了?

What have I missed? What is wrong?

推荐答案

PHPMailerAutoload *(require_once)

这篇关于PHPMailer说该类不存在,但确实存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆