Using PHP 8 and phpmailer 6.2 (phpmailer script not sending email anymore)

IT Tutorials

Today I’ve istalled on a server Windows Server 2019 a new version of Xampp with PHP version 8 and after a few tests I’ve noticed that mails are not sending anymore from my php scripts.

After some research I found that phpmailer older versions like 5.2.14 that I am using from a long time ago is not compatible anymore with PHP8 .

I have changed the script with the latest phpmailer 6.2 version, compatible with php 8, but still not working .

Again after a few time spent searching a found that calling phpmailer with require_once(“phpmailer/PHPMailerAutoload.php”); is not enough, so you need to use :

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

in your php scripts required for sending email via phpmailer 6.2 version .

Good luck !

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 4.17 out of 5)
Loading...


Lost Password