Phpmailer not sending emails

I had installed phpmailer successfully, but I am still unable to send emails. I had followed this topic as well, but still did not succeed(I’ll get http error 500, this page isn’t working). “Class PHPMailer not found”.
My code is as follows:

<?php require 'constants.php'; require 'vendor/phpmailer/phpmailer/src/Exception.php'; require 'vendor/phpmailer/phpmailer/src/PHPMailer.php'; require 'vendor/phpmailer/phpmailer/src/SMTP.php'; //PHPMailer Object $mail = new PHPMailer; //From email address and name $mail->From = ""; $mail->FromName = "Full Name"; //To address and name $mail->addAddress("", "Recepient Name");//Recipient name is optional $mail->addAddress(""); //Address to which recipient will reply $mail->addReplyTo("", "Reply"); //CC and BCC $mail->addCC(""); $mail->addBCC(""); //Send HTML or Plain Text email $mail->isHTML(true); $mail->Subject = "Subject Text"; $mail->Body = "Mail body in HTML"; $mail->AltBody = "This is the plain text version of the email content"; if(!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent successfully"; } if(!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent successfully"; }

Hi Hossein, which version of PHPmailer you are using? Also please see my answer on your mentioned thread carefully. It can solve your error. If still the error not solved please upload the code to GitHub or give me the FTP access to it.

Hi shahroze, thanks for replying, I now have checked for the error I get: it shows this:
Warning: require(vendor/phpmailer/phpmailer/src/Exception.php): failed to open stream: No such file or directory in…
This error shows for these 3 lines:

require ‘vendor/phpmailer/phpmailer/src/Exception.php’;
require ‘vendor/phpmailer/phpmailer/src/PHPMailer.php’;
require ‘vendor/phpmailer/phpmailer/src/SMTP.php’;

with that said, I already installed phpmailer . Thanks for your help

I found the solution. what I did was moving the vendor folder inside my public_html folder, that did the trick for me:)

Thank you @Hossein for updating us with the solution.