Php mailer issue

getting this error while running saumys-classes.rf.gd/mail.php
Warning : require(vendor/autoload.php): failed to open stream: No such file or directory in /home/vol11_2/epizy.com/epiz_33817662/htdocs/mail.php on line 7

Fatal error : require(): Failed opening required ‘vendor/autoload.php’ (include_path=‘.:/usr/share/pear/’) in /home/vol11_2/epizy.com/epiz_33817662/htdocs/mail.php on line 7
my code
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
// Load Composer’s autoloader
require ‘vendor/autoload.php’;
// Instantiation
$mail = new PHPMailer(true);
// Server settings
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Debugoutput = ‘html’;
$mail->Host = ‘smtp.gmail.com’;
$mail->SMTPAuth = true;
$mail->SMTPSecure= ‘tls’;
$mail->Port = 587;
$mail->Username = ‘ENTER YOUR GOOGLE ACCOUNT EMAIL’;
$mail->Password = ‘ENTER YOUR APP PASSWORD HERE’;
// Sender & Recipient
$mail->From = ‘ENTER YOUR GOOGLE ACCOUNT EMAIL’;
$mail->FromName = ‘SENDER NAME’;
$mail->addAddress(‘RECIPIENT EMAIL’);
// Content
$mail->isHTML(true);
$mail->CharSet = ‘UTF-8’;
$mail->Encoding = ‘base64’;
$mail->Subject = ‘Subject’;
$body = ‘This is a test message’;
$mail->Body = $body;
if($mail->send()){
echo ‘Success Message’;
exit;
}else{
echo ‘Error Message’;
exit;
}
?>

Your code is trying to load in code from Composer, but the Composer autoloader file vendor/autoload.php doesn’t exist in the location the code is looking for.

Please fetch the Composer dependencies on your own computer and upload the generated vendor folder to your account.


If what I just said is complete gibberish to you: PHPMailer has some additional installation steps that require some developer tools to use. If you don’t want to be bother with that, you may wish to use a script that has all the dependencies packed in, such as our contactform template.

5 Likes

thank you admin i would let you know if i succeed

This code is working thank you @Admin

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.