我工作的一个项目,我需要发送电子邮件用户输入电子邮件地址和密码后。他们可以激活他们发送电子邮件的帐户点击。但是当我使用PHPMailer时出现错误。错误是像新的PHPMailer需要PHPMailerAutoload.php?
Fatal error: Uncaught Error: Class 'PHPMailer\PHPMailer' not found in C:\xampp\htdocs\E-Commerce-New-2\registration.php:20 Stack trace: #0 {main} thrown in C:\xampp\htdocs\E-Commerce-New-2\registration.php on line 20
在新的PHPMailer版本使用PHPMailerAutoload.php文件?我认为答案是否定的。
我尝试使用该代码$mail = new PHPMailer\PHPMailer();
,也验证码$mail = new PHPMailer();
还没有人工作。我把我的文件结构向下跌破
而且在这里我过去我的代码行。
<?php
session_start();
include("includes/db.php");
include("functions/functions.php");
include('PHPMailer/PHPMailer.php');
?>
<?php
// If the values are posted, insert them into the database.
if (isset($_POST['email']) && isset($_POST['password'])){
$email = $_POST['email'];
$password = $_POST['password'];
$verification_key = md5($email);
$query = "INSERT INTO `customers` (customer_pass,customer_email,verification_key) VALUES ('$password', '$email','$verification_key')";
$result = mysqli_query($con, $query);
if($result){
$mail = new PHPMailer\PHPMailer();
$mail->setFrom('[email protected]clickshop.com');
$mail->addAddress($email,'test');
$mail->Subject = "Verify Your Account";
$mail->isHTML(true);
$mail->Body = ' Please verify your email address to activate your account by clicking on this link <br>
<a href="http://localhost/E-Commerce-New-2/verify.php?key="'. $verification_key.'>Click Here</a>';
if(!$mail->send()) {
$fmsg= 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo;
} else {
$smsg = 'User Registration successfull. Please Check your email to Activate Account!';
}
}else{
$fmsg = "User registration failed";
}
}
?>
有人可以给我一个建议吗?
有些人否决没有解释任何理由 –
你真的需要把在短短的最小的量的努力来解决这个问题 - 这可能是为什么你得到downvotes。阅读PHPMailer附带的自述文件,并将代码基于所提供的示例。花费3小时努力的 – Synchro
可能不多?我知道了。谢谢你的建议 –