• Resolved yezzz

    (@yezzz)


    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 4 years ago by yezzz.
    • This topic was modified 4 years ago by yezzz. Reason: removed part of the url
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author tuxlog

    (@tuxlog)

    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

    Thread Starter yezzz

    (@yezzz)

    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.

    Thread Starter yezzz

    (@yezzz)

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

    Thread Starter yezzz

    (@yezzz)

    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 4 years ago by yezzz.
    Plugin Author tuxlog

    (@tuxlog)

    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.

    Thread Starter yezzz

    (@yezzz)

    Thread Starter yezzz

    (@yezzz)

    Yes, v5.9 seems to work well ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘fatal error’ is closed to new replies.