My Problem is that PHP mailer works on my local machine, but does not work when I deploy the script to my AWS Lightsail server.
I have tried setting the proper file (644) and folder(755) permissions, still nothing works.
I have the function deployed on other servers, without any issue
The error message
PHP Fatal error: Uncaught Error: Class 'PHPMailer\PHPMailer\PHPMailer' not found in
How I include the mail function
require('transit/mail.php');
The content of my mail function.
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
function send_mail($sender, $senderName, $recipient, $subject, $bodyText, $bodyHtml){
I have solved the issue. These are the steps I followed.
composer require phpmailer/phpmailer
This was the message received.
Using version ^6.1 for phpmailer/phpmailer ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Writing lock file Generating autoload files
It worked afterwards.