PHPMailer Not found


Trying simple php mail and running into following error.

'PHP message: PHP Fatal error: Uncaught Error: Class “PHPMailer\PHPMailer\PHPMailer” not found

My send_email.php script is as following


ini_set('display_errors', 1);

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;


    // Create a new PHPMailer instance
    $mail = new PHPMailer(true);
    $mail->SMTPDebug = 4;

    try {
        $name = $_POST["name"];
        $email = $_POST["email"];
        $message = $_POST["message"];

        // Server settings
        //$mail->SMTPDebug = SMTP::DEBUG_SERVER;
        //$mail->Host = ''; // Specify your SMTP server
        $mail->Host = "localhost";
        $mail->SMTPAuth = false; // Enable SMTP authentication
        //$mail->Username = '[email protected]'; // SMTP username
        //$mail->Password = ''; // SMTP password
        //$mail->SMTPSecure = 'tls'; // Enable TLS encryption
        //$mail->Port = 587; // TCP port to connect to

        // Sender and recipient settings
        $mail->setFrom('[email protected]', 'xyz'); // Sender's email and name
        $mail->addAddress('[email protected]', 'abc'); // Recipient's email and name

        // Email content
        $mail->isHTML(true); // Set email format to HTML
        $mail->Subject = 'Subject of the Email';
        $mail->Body = 'This is the HTML message body';
        $mail->AltBody = 'This is the plain text message body for non-HTML email clients';

        // Send the email
        echo $mail->SMTPDebug;
        echo $mail->SMTPDebug;
        echo 'success';
    } catch (Exception $e) {
        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";

My hesita CP version is v1.8.8

Any help would be appreciated


Just to confirm when I run /usr/local/hestia/bin/v-add-sys-dependencies as root, it just returns without displaying anything.

If you run it from your website you need to run phpmailer your self