I use phpMailer for the processing of mail sent from the website. This morning I suddenly got the following message:
Fatal error: __autoload() is no longer supported, use spl_autoload_register() instead in C:xampphtdocswebappPHPMailerAutoload.php on line 45
I have PHP 8.0.0 running on the server
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($classname)
{
PHPMailerAutoload($classname);
}
}
3
Answers
You’re using a very old version of PHPMailer – that code has not been in PHPMailer for 3 years. PHP 8.0 is officially supported as of PHPMailer 6.2.0, and make sure you read the upgrade guide.
Your issue will be resolved by changing
function __autoload($classname) to function spl_autoload_register($classname)
which has no adverse affect on the output.
This is An Edited AutoLoad File in:
PHPMailerPHPMailerAutoload.php
Changes are done here:
spl_autoload_register($classname);
Thanks