Skip to:

Opened 4 years ago

Closed 4 years ago

#8347 closed defect (bug) (fixed)

The way we check PHPMailer v6 is available can generate errors

Reported by: imath's profile imath Owned by: imath's profile imath
Milestone: 6.3.0 Priority: high
Severity: major Version: 6.2.0
Component: Core Keywords: has-patch commit


We haven't identified this issue during 6.2.0-beta because to get these errors the Mailer class needs to be overriden using the bp_phpmailer_object filter.

In this particular case, as we set the $phpmailer_is_6_0 check only if the Mailer class is not set, then we get an error as explained on this forum topic

To fix this issue, we need to set the $phpmailer_is_6_0 check immediately after we made sure the version 6 of PHPMailer is available (or in other words that WordPress is 5.5).

See attached patch.

Attachments (2)

8437.patch (1.0 KB) - added by imath 4 years ago.
8347.02.patch (1014 bytes) - added by r-a-y 4 years ago.

Download all attachments as: .zip

Change History (8)

4 years ago

#1 @dcavins
4 years ago

I'm not understanding the problem. What is the combination of factors that causes this error to arise? I'm not seeing it on my test installation.

#2 @imath
4 years ago

Hi @dcavins

Here's how you can replicate the issue, add this code into a bp-custom.php file:

function override_bp_phpmailer_object() {
	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';

	$phpmailer = new PHPMailer\PHPMailer\PHPMailer( true );
	return $phpmailer;
add_filter( 'bp_phpmailer_object', 'override_bp_phpmailer_object' );

Then create a private group with a user and with another user, go to the group's landing page, and click on the Request membership Group's navigation (not the header's button).

You should see a fatal ;)

4 years ago

#3 @r-a-y
4 years ago

Confirmed that the patch from imath fixes things.

02.patch is a slight tweak to check against the WP version instead of using file_exists() to determine if the new PHPMailer class is available.

#4 @imath
4 years ago

  • Keywords commit added

Thanks for your feedback and improvements @r-a-y

#5 @imath
4 years ago

In 12708:

Use the right PHPMailer version even if default mailer is overridden

Props r-a-y, dcavins

See #8347 (Trunk)

#6 @imath
4 years ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 12709:

Use the right PHPMailer version even if default mailer is overridden

Props r-a-y, dcavins

Fixes #8347 (Branch 6.0)

Note: See TracTickets for help on using tickets.