Skip to content

Commit

Permalink
Fix inaccurate PHPMailer 'Date' timestamp when auto-connect is on and…
Browse files Browse the repository at this point in the history
… when using IMAP mode.

BuddyPress uses a static version of PHPMailer:
https://buddypress.trac.wordpress.org/browser/tags/2.8.2/src/bp-core/classes/class-bp-phpmailer.php?marks=28,39,47#L27

When RBE is using IMAP mode with auto-connect turned on, BP's PHPMailer
would never change the 'Date' header from when it was first initialized.

This meant that subsequent emails would all use the older timestamp, which
is wrong!

This commit remedies this by always setting the 'Date' field when IMAP mode
and auto-connect is on.

See #23.
  • Loading branch information
r-a-y committed Apr 20, 2017
1 parent a16d7e2 commit bc03b3e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bp-rbe-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,13 @@ public function set_bp_email_headers( $retval, $email ) {
'Reply-To' => $reply_to
) );

// Fix issues with PHPmailer date when IMAP auto-connect is in effect.
if ( ! bp_rbe_is_inbound() && 1 === (int) bp_rbe_get_setting( 'keepaliveauto' ) ) {
add_action( 'phpmailer_init', function( $p ) {
$p->MessageDate = date( 'D, j M Y H:i:s O' );
} );
}

return $retval;
}

Expand Down

0 comments on commit bc03b3e

Please sign in to comment.