Phpmailer not sending emails


#1

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 = "support@sprood.com"; $mail->FromName = "Full Name"; //To address and name $mail->addAddress("arcasrak@gmail.com", "Recepient Name");//Recipient name is optional $mail->addAddress("recepient1@example.com"); //Address to which recipient will reply $mail->addReplyTo("reply@yourdomain.com", "Reply"); //CC and BCC $mail->addCC("cc@example.com"); $mail->addBCC("bcc@example.com"); //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"; }

#2

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.


#3

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


#4

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


#5

Thank you @Hossein for updating us with the solution.