Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Class 'PHPMailer' not found

Tags:

php

phpmailer

  • I tried :include_once('C:\Inetpub\wwwroot\php\PHPMailer\PHPMailerAutoload.php');

Fatal error: Class 'PHPMailer' not found in C:\Inetpub\wwwroot\php\index.php on line 151

I place the PHPMailerAutoload.php in the same directory as my script.

Can someone help me with this ?

like image 362
iori Avatar asked Mar 06 '15 19:03

iori


Video Answer


1 Answers

all answers are outdated now. Most current version (as of Feb 2018) does not have autoload anymore, and PHPMailer should be initialized as follows:

<?php    require("/home/site/libs/PHPMailer-master/src/PHPMailer.php");   require("/home/site/libs/PHPMailer-master/src/SMTP.php");      $mail = new PHPMailer\PHPMailer\PHPMailer();     $mail->IsSMTP(); // enable SMTP      $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only     $mail->SMTPAuth = true; // authentication enabled     $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail     $mail->Host = "smtp.gmail.com";     $mail->Port = 465; // or 587     $mail->IsHTML(true);     $mail->Username = "xxxxxx";     $mail->Password = "xxxx";     $mail->SetFrom("[email protected]");     $mail->Subject = "Test";     $mail->Body = "hello";     $mail->AddAddress("[email protected]");       if(!$mail->Send()) {         echo "Mailer Error: " . $mail->ErrorInfo;      } else {         echo "Message has been sent";      } ?> 
like image 103
avs099 Avatar answered Sep 21 '22 04:09

avs099