我工作的一個項目,我需要發送電子郵件用戶輸入電子郵件地址和密碼後。他們可以激活他們發送電子郵件的帳戶點擊。但是當我使用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
可能不多?我知道了。謝謝你的建議 –