Title: Uncaught TypeError
Last modified: August 20, 2021

---

# Uncaught TypeError

 *  Resolved [rverdons](https://wordpress.org/support/users/rverdons/)
 * (@rverdons)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/uncaught-typeerror-52/)
 * Hi
 * I just updated to:
    WP-Mail-SMTP 3.0.3 Wordpress 5.8 PHP 8.0
 * Now I get this error:
 * Fatal error: Uncaught TypeError: WPMailSMTP\Providers\MailerAbstract::__construct():
   Argument #1 ($phpmailer) must be of type WPMailSMTP\MailCatcherInterface, PHPMailer\
   PHPMailer\PHPMailer given, called in /www/wp-content/plugins/wp-mail-smtp/src/
   Providers/Gmail/Mailer.php on line 47 and defined in /www/wp-content/plugins/
   wp-mail-smtp/src/Providers/MailerAbstract.php:104
    Stack trace: #0 /www/wp-content/
   plugins/wp-mail-smtp/src/Providers/Gmail/Mailer.php(47): WPMailSMTP\Providers\
   MailerAbstract->__construct(Object(PHPMailer\PHPMailer\PHPMailer)) #1 /www/wp-
   content/plugins/wp-mail-smtp/src/Providers/Loader.php(195): WPMailSMTP\Providers\
   Gmail\Mailer->__construct(Object(PHPMailer\PHPMailer\PHPMailer)) #2 /www/wp-content/
   plugins/wp-mail-smtp/src/Providers/Loader.php(151): WPMailSMTP\Providers\Loader-
   >get_entity(‘gmail’, ‘Mailer’) #3 /www/wp-content/plugins/wp-mail-smtp/src/Admin/
   Review.php(106): WPMailSMTP\Providers\Loader->get_mailer(‘gmail’, Object(PHPMailer\
   PHPMailer\PHPMailer)) #4 /www/wp-content/plugins/wp-mail-smtp/src/Admin/Review.
   php(78): WPMailSMTP\Admin\Review->review() #5 /www/wp-includes/class-wp-hook.
   php(303): WPMailSMTP\Admin\Review->review_request(”) #6 /www/wp-includes/class-
   wp-hook.php(327): WP_Hook->apply_filters(NULL, Array) #7 /www/wp-includes/plugin.
   php(470): WP_Hook->do_action(Array) #8 /www/wp-admin/admin-header.php(287): do_action(‘
   admin_notices’) #9 /www/wp-admin/plugins.php(603): require_once(‘/www/wp-admin/
   a…’) #10 {main} thrown in /www/wp-content/plugins/wp-mail-smtp/src/Providers/
   MailerAbstract.php on line 104
 * I disabled my plugins 1 by 1 and the error dissapears when I disable WP Mail 
   SMTP.
 * Can you help me with this?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Gregor Capuder](https://wordpress.org/support/users/capuderg/)
 * (@capuderg)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/uncaught-typeerror-52/#post-14787996)
 * Hi [@rverdons](https://wordpress.org/support/users/rverdons/),
 * did you also update any other parts of your WP site? For example the WordPress
   core version? Also, which version of our plugin did you use before?
 * It looks like the global WordPress core `$phpmailer` variable is being overwritten
   by another plugin or theme.
 * We are expecting to get our MailCatcherV6 object instance in the `WPMailSMTP\
   Providers\MailerAbstract::__construct()` method, and something else is overwriting
   it and providing the `PHPMailer\PHPMailer\PHPMailer` object instead.
 * Please check any Must-Use plugins on your WP site and/or any custom code in `
   wp-config.php` file. Hosting companies usually make some overwrites, to improve
   or prevent the email sending via the PHPMailer class…
 * You already said you disabled your plugins one by one… Could you also please 
   disable all plugins except our WP Mail SMTP? And see if this error still occurs?
 * If it does not, then some other plugin is causing this issue (maybe one that 
   is also sending emails?).
 * Let me know how it goes.
 * Take care!
 * PS: I tested our plugin (v3.0.3 with the Gmail mailer) on PHP 8, on WP 5.8 and
   didn’t experience this issue.
 *  Thread Starter [rverdons](https://wordpress.org/support/users/rverdons/)
 * (@rverdons)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/uncaught-typeerror-52/#post-14789314)
 * Hi Gregor,
    Thanks for your fast response!
 * I also update all other plugins and my theme. I am not sure about the core version:
   I just updated Worpress. Is the core something separate?
 * I did the check you suggested: disable all plugins except WP Mail SMTP: still
   the same error.
 * I found a piece of code in my `wp-config.php` related to phpmailer. It is placed
   there by my hosting company (Transip). To me it doesn’t seem to replace the PHPMailer
   class, it just changes a setting, right?
 *     ```
       /** TransIP fix: sendmail does not support flags. This fix is needed in order to make mailing work. */
       global $phpmailer;
       if ((!is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' )) &&
            file_exists(ABSPATH . '/wp-includes/class-phpmailer.php') &&
            file_exists(ABSPATH . '/wp-includes/class-smtp.php')) {
       	require_once ABSPATH . '/wp-includes/class-phpmailer.php';
       	require_once ABSPATH . '/wp-includes/class-smtp.php';
       	$phpmailer = new PHPMailer( true );
       }
       $phpmailer->UseSendmailOptions = false;
       ```
   
 *  Plugin Author [Gregor Capuder](https://wordpress.org/support/users/capuderg/)
 * (@capuderg)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/uncaught-typeerror-52/#post-14794233)
 * Hi [@rverdons](https://wordpress.org/support/users/rverdons/),
 * what happens, if you try to remove this block of code and save the file? Is the
   issue still present?
 * By WordPress Core I mean WordPress. So you are all good.
 * Did you also check the `mu-plugins` must-use plugins folder (if it exists)? And
   also try to switch to another theme, maybe the theme also has some custom mailing
   code in it.
 * Let me know how it goes.
 * Take care!
 *  Thread Starter [rverdons](https://wordpress.org/support/users/rverdons/)
 * (@rverdons)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/uncaught-typeerror-52/#post-14796749)
 * Hi
 * I tried another theme (a default WP theme): doesn’t solve the issue.
    The mu-
   plugins folder is empty.
 * I just disabled that piece of phpmailer code in my wp-config.php: That makes 
   the issue go away!
 * So for me this issue is solved now. I’ll work with my hosting provider to see
   if there can be any side effects of disabling the code. Thanks for your help!
 * Robert
 *  Plugin Author [Gregor Capuder](https://wordpress.org/support/users/capuderg/)
 * (@capuderg)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/uncaught-typeerror-52/#post-14798177)
 * Hi Robert,
 * thanks for letting us know. I don’t think removing this code will have any side
   effects, because you are using our plugin to send emails.
 * Have a nice day!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Uncaught TypeError’ is closed to new replies.

 * ![](https://ps.w.org/wp-mail-smtp/assets/icon-256x256.png?rev=1755440)
 * [WP Mail SMTP by WPForms - The Most Popular SMTP and Email Log Plugin](https://wordpress.org/plugins/wp-mail-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-smtp/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Gregor Capuder](https://wordpress.org/support/users/capuderg/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/uncaught-typeerror-52/#post-14798177)
 * Status: resolved