Skip to:

Opened 7 years ago

Closed 7 years ago

#7509 closed defect (bug) (fixed)

BP_PHPMailer needs to set the `Date` header

Reported by: r-a-y's profile r-a-y Owned by: djpaul's profile DJPaul
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.5.0
Component: Emails Keywords: has-patch


I'm using a long-running script that includes sending email with BuddyPress native emails.

What I'm seeing is the Date field is only initialized once during the first send. Subsequent sendouts uses the original date.

The problem is because BuddyPress uses a static version of PHPMailer:,39,47#L27

And PHPMailer doesn't set the Date field again if one already exists:

So subsequent mailouts will be sent out with the wrong date, making new emails hard to view in an email client.

My use-case might be a little specific, but I think it will help if we always set the Date header so other scripts will not run into the same problem as me.

Attachments (1)

7509.01.patch (425 bytes) - added by r-a-y 7 years ago.

Download all attachments as: .zip

Change History (3)

7 years ago

#1 @boonebgorges
7 years ago

  • Milestone changed from Awaiting Review to 2.9

Maybe edge case, but it seems like a flaw in WP's mail date handling nonetheless (one that never really comes up, because even batches of emails are generally expected to be sent out immediately). I'd say go for it.

#2 @r-a-y
7 years ago

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

In 11536:

Emails: Set the 'Date' header for BP_PHPMailer.

Since the BP_PHPMailer class uses a static instance of PHPMailer:,39,47#L27

PHPMailer would only set the Date field for the email on the initial send:

In cases where a long-running script is utilizing BP_PHPMailer,
subsequent emails would be sent out with the wrong Date field, making
these emails hard to find in an email client.

This commit rectifies this by always setting the Date field for our
version of PHPMailer.

Fixes #7509.

Note: See TracTickets for help on using tickets.