I am facing this error "Fatal error: Uncaught Error: Class 'PHPMailer' not found" when I submit the appointment form. The code is working fine on localhost but not working on live server.
On the live server, I have created a directory named "phpmailer" on the root directory of the website where all files are located. The "phpmailer" directory has 4 files:
- class.phpmailer.php
- class.smtp.php
- credentials.php
- PHPMailerAutoload.php
I also make a copy of the file "PHPMailerAutoload.php" out of the "phpmailer" directory, then I edit the file "PHPMailerAutoload.php" and change the path by putting phpmailer.
Here is the email code:
require 'PHPMailerAutoload.php';
require 'phpmailer/credentials.php';
$mail = new PHPMailer; // This line has an error of PHPMailer class not found
$mail->SMTPDebug = 0;
$mail->isSMTP();
$mail->Host = 'smtp.ipage.com';
$mail->SMTPAuth = true;
$mail->Username = EMAIL;
$mail->Password = PASS;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom(EMAIL, 'Symbiosis Home Care');
$mail->addAddress('babarabid123@gmail.com', 'Babar Ali');
$mail->addReplyTo(EMAIL);
$mail->Subject = "Enquiry Form - Symbiosis Home Care";
$mail->Body = 'New Enquiry Received';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else{
if (!empty($i_name)) {
$result='<div class="alert alert-success background-success">
<button aria-label="Close" class="close" data-dismiss="alert" type="button"><i class="fa fa-close"></i></button>Welcome <strong>' . $i_name .',</strong> Thanks For Contacting Us. We Will Get Back To You Soon.</div>';
echo $result;
}
else {}
}