awesomemotive / WP-Mail-SMTP

The most popular WordPress SMTP and PHP Mailer plugin. Trusted by over 3 million sites.
https://wordpress.org/plugins/wp-mail-smtp/
GNU General Public License v3.0
55 stars 34 forks source link

Crash after activation 3.1.0 on WP 5.8.1 #107

Closed kvdb closed 2 years ago

kvdb commented 2 years ago

Expected Behavior

No crash after activation of plugin

Current Behavior

An error of type E_ERROR was caused in line 103 of the file /www/wp-content/plugins/wp-mail-smtp/src/Providers/MailerAbstract.php. Error message: Uncaught TypeError: Argument 1 passed to WPMailSMTP\Providers\MailerAbstract::__construct() must implement interface WPMailSMTP\MailCatcherInterface, instance of PHPMailer\PHPMailer\PHPMailer given, called in /www/wp-content/plugins/wp-mail-smtp/src/Providers/Loader.php on line 196 and defined in /www/wp-content/plugins/wp-mail-smtp/src/Providers/MailerAbstract.php:103 Stack trace: #0 /www/wp-content/plugins/wp-mail-smtp/src/Providers/Loader.php(196): WPMailSMTP\Providers\MailerAbstract->__construct(Object(PHPMailer\PHPMailer\PHPMailer)) #1 /www/wp-content/plugins/wp-mail-smtp/src/Providers/Loader.php(152): WPMailSMTP\Providers\Loader->get_entity('smtp', 'Mailer') #2 /www/wp-content/plugins/wp-mail-smtp/src/Admin/Review.php(106): WPMailSMTP\Providers\Loader->get_mailer('smtp', Object(PHPMailer\PHPMailer\PHPMailer)) #3 /www/wp-content/plugins/wp-mail-smtp/src/Admin/Review.php(78): WPMailSMTP\Admin\Review->review() #4 /www/wp-includes/class-wp-hook.php(303): WPMailSMTP\Admin\Review->review_request('') #5 /www/w

capuderg commented 2 years ago

Hi @kvdb,

this is most probably a plugin, theme, or custom code conflict. Some other part of your site is changing the PHPMailer instance and that causes this issue.

Do you have any other SMTP plugins installed and active? Does your currently active theme have any email sending features?

You could try to disable all plugins and only enable WP Mail SMTP to see if this issue is resolved. Then enable each plugin separately and see which one is causing issues. You could also temporarily activate a different theme to see if the theme is at fault.

And finally, some hosting companies add Must-use plugins where they change the email functionality, so please check if you have any Must-use plugins installed. And also check the wp-config.php file, since they usually add some custom code there as well.

Let me know what you find.

Take care!

kvdb commented 2 years ago

I disabled all plugins, the only enabled WP Mail SMTP, same problem. Same with the theme, went back to the WP default theme, same problem. I've run WP Mail SMTP succcessfully for a month or so. So I assume that an auto WP upgrade broke WP Mail SMTP. Couldn't find any vendor specific plugins either.

capuderg commented 2 years ago

Hi @kvdb,

did you check your wp-config.php file in the root folder of your WP site? Some hosting companies add custom PHPmailer code in that file...

There has to be some code on your site that is causing this issue (setting the default PHPMailer object, overwriting our changes).

Take care!

kvdb commented 2 years ago

You were right, this seems to be the modification from the hoster I disabled. Then everything is fine:

/** 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;

capuderg commented 2 years ago

I'm glad you found it 👍

Have a nice day!