Make WordPress Core

Opened 2 years ago

Last modified 12 hours ago

#41750 accepted enhancement

Update PHPMailer to 6.0

Reported by: Synchro Owned by: SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version:
Component: External Libraries Keywords: has-patch needs-testing needs-dev-note early needs-refresh
Focuses: Cc:
PR Number:


PHPMailer 5.2 has now been deprecated and PHPMailer 6.0 has been released. Minimum requirements have been increased to PHP 5.5 and it now has a namespace, which will require changes in WP's use of it.

Attachments (2)

41750.diff (243.6 KB) - added by SergeyBiryukov 4 months ago.
41750.2.diff (242.1 KB) - added by desrosj 4 months ago.

Download all attachments as: .zip

Change History (22)

#1 @netweb
2 years ago

Related: #40472 Update PHPMailer to 5.2.25

cc @MattyRob

#3 @johnbillion
2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

As the WordPress project is a long way from requiring PHP 5.5 as a minimum, updating to PHPMailer 6 isn't on the cards, unless somebody wants to maintain a fork that's compatible with PHP 5.2.

Closing as maybelater. We'll get there eventually.

#4 @johnbillion
2 years ago

  • Version trunk deleted

#5 @ocean90
15 months ago

#45276 was marked as a duplicate.

#6 @SergeyBiryukov
4 months ago

  • Keywords needs-patch added
  • Milestone set to Future Release
  • Resolution maybelater deleted
  • Status changed from closed to reopened

Reopening. As of WordPress 5.2, PHP 5.6.20+ is required, so if that was the remaining limitation in upgrading, it shouldn't be a blocker anymore.

#7 @SergeyBiryukov
4 months ago

#45822 was marked as a duplicate.

#8 @SergeyBiryukov
4 months ago

  • Keywords has-patch needs-testing needs-dev-note added; needs-patch removed
  • Milestone changed from Future Release to 5.3

41750.diff seems to work in my testing, bumping PHPMailer to the latest release, 6.0.7 at the moment.

Per the Stack Overflow thread and upgrading notes, the biggest change for us is probably the introduction of the PHPMailer\PHPMailer\PHPMailer namespace:

The reason this class ends up with this "triple name" is because it's the PHPMailer class, in the PHPMailer project, owned by the PHPMailer organisation. This allows it to be differentiated from other forks of PHPMailer, other projects by the PHPMailer organisation, and other classes within the project.

With enough testing and a dev note, I think this can still make it into 5.3.

4 months ago

#9 @desrosj
4 months ago

41750.2.diff updates the MockPHPMailer class to extend the PHPMailer class at the correct new namespace.

Also, it looks like PHPMailer now includes its own Exception class that is used by default. The only thing that class does is wrap exception messages in HTML. 41750.2.diff adds a preceding \ to all Exception occurrences to use the globally namespaced Exception instead.

There are still some unit test failures that need to be investigated.

#10 @Synchro
4 months ago

FWIW, I'm, very happy to see this update going ahead, thanks for getting it into WP!

Version 0, edited 4 months ago by Synchro (next)

#11 @SergeyBiryukov
4 months ago

#48072 was marked as a duplicate.

#12 @Hareesh Pillai
4 months ago

  • Component changed from Mail to External Libraries

#13 @davidbaumwald
4 months ago

@desrosj Is this something that make it in for Beta 1 of version 5.3 tomorrow, or do the test failures still need investigating?

#14 @desrosj
4 months ago

  • Milestone changed from 5.3 to 5.4

I think we should play this one safe and punt. @SergeyBiryukov if you feel otherwise, feel free to move it back.

#15 follow-up: @Synchro
4 months ago

I'm not sure when your deadline is for 5.3, but there are some reasonably important bug fixes in the pipeline for PHPMailer.

#16 in reply to: ↑ 15 @jrf
3 months ago

  • Keywords early added

Replying to Synchro:

I'm not sure when your deadline is for 5.3, but there are some reasonably important bug fixes in the pipeline for PHPMailer.

@Synchro Hi Marcus, sorry that nobody replied to you before, but WP 5.3 has already gone into feature freeze.

An upgrade like this will need plenty of testing as the impact could be large if not done 100% correctly, not just for WP itself, but also for plugins/themes using the functionality provided via WP, so should preferably be made early in a release cycle.

#17 @nasiralamreeki
2 months ago

WordPress really needs to take more seriously updating external libraries. Years between updating libraries from upstream is unacceptable. There’s tremendous benefits to getting these libraries updated faster.

We can’t wait for theme and plugin developers forever to test. Sometimes we have to push the web forward by pushing ahead with changes even if they break themes and plugins as this in turn will push developers to update their code.

We pushed Gutenberg ahead even though most major themes and plugins weren’t ready for it.

#18 @davidbaumwald
14 hours ago

  • Keywords needs-refresh added

The latest patch no longer applies cleanly, so it needs-refresh. @desrosj given that, is this doable for 5.4?

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.

12 hours ago

#20 @SergeyBiryukov
12 hours ago

  • Owner set to SergeyBiryukov
  • Status changed from reopened to accepted
Note: See TracTickets for help on using tickets.