Make WordPress Core

Opened 7 years ago

Last modified 14 months ago

#25253 reopened defect (bug)

Fatal error: Cannot redeclare class phpmailerException

Reported by: hovida Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6
Component: Mail Keywords: has-patch needs-testing
Focuses: Cc:

Description (last modified by SergeyBiryukov)

All Plugins Disabled, all Themes disabled - Reinstalled - All the same error:


Fatal error: Cannot redeclare class phpmailerException in /homepages/23/d471228603/htdocs/wp-includes/class-phpmailer.php on line 2825

Same Problem when i use wp_mail on Cron shedules, see:

Attachments (1)

pluggable.diff (502 bytes) - added by pixelbath 4 years ago.
Patch to check whether the PHPMailer class exists prior to require_once

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
7 years ago

  • Component changed from Accessibility to Mail
  • Description modified (diff)
  • Summary changed from PHPMailer to Fatal error: Cannot redeclare class phpmailerException

#2 @SergeyBiryukov
7 years ago

  • Keywords reporter-feedback added; needs-patch removed

Could not reproduce the issue neither with the password reset form nor with your plugin from the forum topic, it works fine for me.

The only place in core where class-phpmailer.php is included is wp_mail(), but it first checks if $phpmailer global is defined, and it uses require_once rather than just require: tags/3.6/wp-includes/pluggable.php#L223.

I can only reproduce this fatal error if I manually include class-phpmailer.php twice outside of wp_mail().

Last edited 7 years ago by SergeyBiryukov (previous) (diff)

#3 @chriscct7
5 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Closing as worksforme. Feel free to reopen if you can provide steps to reproduce

#4 @pixelbath
4 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Was able to reproduce this problem using a global error handler that included its own phpMailer script. Pluggable.php does check if the $phpmailer global is defined, but not whether the base class exists (which would mean it's been included, but not initialized). Submitting a patch.

4 years ago

Patch to check whether the PHPMailer class exists prior to require_once

#5 @SergeyBiryukov
4 years ago

  • Milestone set to Awaiting Review

#6 @cbutlerjr
4 years ago

  • Keywords has-patch needs-testing added
Note: See TracTickets for help on using tickets.