WPIntell

Source evidence

fatal error

wp-greet · support · 2020-11-15T00:41:00+00:00

mixedsentiment
highseverity
0.88relevance
7replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

6 / 34 rows with source links

17.6% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

28 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
yezzz resolved
Fatal error: Class ‘PHPMailer\PHPMailer\PHPMailer’ not found in …\wp-content\plugins\wp-greet\wpg-func-mail.php on line 48 Occurs on wp version 4.9.x … probably due to the use statement, which should be inside if ( (float) $wp_version >= 5.5 ) { } This topic was modified 5 years, 6 months ago by yezzz . This topic was modified 5 years, 6 months ago by yezzz . Reason: removed part of the url Hello yezzz, thank you for this hint. Can you please give the PHP and WordPress Version you are using? It is easier to rebuild the error then. Thanks Sure. PHP 7.2, WP 4.9.16. BTW, moving the use statement inside the condition mentioned above is also not possible (giving fatal error). I just learned that the statement cannot be used inside block scope, so it should be handled differently. Maybe you should use wp_mail() or global $phpmailer. Check out class handling in wp_mail source If wp_mail() or global $phpmailer requires too many changes then you can use class_alias . The following works fine for me, but you need to check for wp => 5.5 //use PHPMailer\PHPMailer\PHPMailer as PHPMailer; if ( (float) $wp_version >= 5.5 ) { if ( ! class_exists( 'PHPMailer\\PHPMailer\\PHPMailer' ) ) { require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php'; require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; require_once ABSPATH . WPINC . '/PHPMailer/Exception.php'; } class_alias('PHPMailer\PHPMailer\PHPMailer','PHPMailer'); } else { Alternatively you could create another alias for both cases and extend that. This reply was modified 5 years, 6 months ago by yezzz . Thanks for all your hints. I decided to separate this in two files and include accordingly. So, I can better make changes if necessary for future releases. I will publish it in a few minutes. Please test it and let me know if the problem is gone. Will test it… in the meantime had some fun with thickbox … Yes, v5.9 seems to work well 🙂

Comments

7 shown
tuxlog 2020-11-15T06:29:00+00:00

Hello yezzz, thank you for this hint. Can you please give the PHP and WordPress Version you are using? It is easier to rebuild the error then. Thanks

yezzz 2020-11-15T15:28:00+00:00

Sure. PHP 7.2, WP 4.9.16. BTW, moving the use statement inside the condition mentioned above is also not possible (giving fatal error). I just learned that the statement cannot be used inside block scope, so it should be handled differently.

yezzz 2020-11-15T16:05:00+00:00

Maybe you should use wp_mail() or global $phpmailer. Check out class handling in wp_mail source

yezzz 2020-11-18T14:24:00+00:00

If wp_mail() or global $phpmailer requires too many changes then you can use class_alias . The following works fine for me, but you need to check for wp => 5.5 //use PHPMailer\PHPMailer\PHPMailer as PHPMailer; if ( (float) $wp_version >= 5.5 ) { if ( ! class_exists( 'PHPMailer\\PHPMailer\\PHPMailer' ) ) { require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php'; require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; require_once ABSPATH . WPINC . '/PHPMailer/Exception.php'; } class_alias('PHPMailer\PHPMailer\PHPMailer','PHPMailer'); } else { Alternatively you could create another alias for both cases and extend that. This reply was modified 5 years, 6 months ago by yezzz .

tuxlog 2020-11-18T17:48:00+00:00

Thanks for all your hints. I decided to separate this in two files and include accordingly. So, I can better make changes if necessary for future releases. I will publish it in a few minutes. Please test it and let me know if the problem is gone.

yezzz 2020-11-19T00:17:00+00:00

Will test it… in the meantime had some fun with thickbox …

yezzz 2020-11-20T18:43:00+00:00

Yes, v5.9 seems to work well 🙂