SparkPost / wordpress-sparkpost

WordPress plugin to use SparkPost email
https://wordpress.org/plugins/sparkpost/
20 stars 15 forks source link

Deprecated notice on WP 5.5 #155

Closed xoref closed 4 years ago

xoref commented 4 years ago

Problem

Even with the recently updated SparkPost plugin, we're still seeing a 'Deprecated' notice on every request:

Deprecated: class-phpmailer.php is deprecated since version 5.5.0! Use wp-includes/PHPMailer/PHPMailer.php instead. 
The PHPMailer class has been moved to wp-includes/PHPMailer subdirectory and now uses the PHPMailer\PHPMailer namespace. in /var/www/html/website/wp-includes/functions.php on line 4963

Triggered by: https://github.com/SparkPost/wordpress-sparkpost/blob/master/mailer.http.class.php#L8

Suggested fix

Instead of using

require_once ABSPATH . WPINC . '/class-phpmailer.php';

You can use the following to get rid of the deprecated notice:

require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';

class_alias( \PHPMailer\PHPMailer\PHPMailer::class, 'PHPMailer' );
class_alias( \PHPMailer\PHPMailer\Exception::class, 'phpmailerException' );
xoref commented 4 years ago

Code Notice while sending the test email:

Accessing static property WPSparkPost\SparkPostHTTPMailer::$LE as non static

I'll fix both issues and submit a PR shortly.

xoref commented 4 years ago

PR: https://github.com/SparkPost/wordpress-sparkpost/pull/156