[wp-trac] [WordPress Trac] #40390: Wrong time (and date) in mail header send by phpmailer

WordPress Trac noreply at wordpress.org
Fri Apr 7 12:47:42 UTC 2017


#40390: Wrong time (and date) in mail header send by phpmailer
--------------------------+-----------------------------
 Reporter:  Drivingralle  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Mail          |    Version:  4.7.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I noticed that some mail clients show wrong time and sometimes date
 (around midnight) while forwarding or otherwise dealing with emails. For
 ex. MS Outlook gets it wrong.
 The offset is the same as my local timeoffset to UTC.

 Tracking it down this is because the {{{rfcDate()}}} within ''wp-includes
 /class-phpmailer.php'' uses {{{date_default_timezone_get()}}} to add the
 date and time into the mail header. This value is forced by WP to be UTC.

 Debugging rfcDate() with:
 {{{
 error_log( var_export( date_default_timezone_get(), true ) );
 error_log( var_export( date('D, j M Y H:i:s O'), true ) );
 error_log( var_export( current_time( 'D, j M Y H:i:s O' ), true ) );
 }}}

 I get:
 {{{
 [07-Apr-2017 12:01:02 UTC] 'UTC'
 [07-Apr-2017 12:01:02 UTC] 'Fri, 7 Apr 2017 12:01:02 +0000'
 [07-Apr-2017 12:01:02 UTC] 'Fri, 7 Apr 2017 14:01:02 +0000'
 }}}

 I read this ticket #39595 and I guess it will not be changed.
 The ticket also says there is no WP function using the native timezone
 getter. This shows there is. Or at least a lib within core.

 Can we modify the phpmailer class to use {{{current_time()}}} or do we
 need to set and reset the timezone before and after every phpmailer call?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40390>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list