On Fr. 27. Jan. 2006, 11:51:55, guest wrote:
Show quoted text> Hi,
>
> Environment: Solaris 8. Using very basic setup, straight out of perldoc
> page, for attachments, results in emails being sent, but with a
> timestamp of 1 hour before actual time.
>
> Ie. an email sent at 16:45, is delivered in to the mailbox as 15:46.
>
> Cheers,
>
> Richard
Hello,
Problem: since MIME-Lite-3.01_05 MIME::Lite auto-generateѕ SMTP-header Date:
to conform to RFC 2822; therefore it has to calculate the time offset
from UTC time to local time (the timezone the host is in).
Cause: the calculation was not performed by using the
current time, but by using the fixed date 1970-01-01; this
always resulted in the offset from UTC to the local timezone
at 1970-01-01 (i.e. +0100 for Europe/Berlin).
Example Date: field:
Date: Thu, 6 Apr 2006 10:04:04 +0100
The users MUA application reads the SMTP-header Date:,
parses the field, calculates a UTC time value by adding/subtracting
the offset, and re-formats the result to local the timezone of the user
and displays it.
Date: displayed as:
Thu, 6 Apr 2006 11:04:04 CEST
If the sender hosts local timezone switches between normal time
and daylight saving time (DST), the offset between these time modes
was never included in the calculation; therefore emails seemed to
come from the past or the future...
Solution: use the current time to calculate the offset between UTC and
the timezone's DST mode.
See patch included below.
WARNING: Please review the following patch, as I find time
calculations confusing... So I am not shure, if I have missed
something.
Patch: MIME-Lite-3.01_05.bug_17319.Date_UTC_offset.patch
diff -urN MIME-Lite-3.01_05-vanilla/lib/MIME/Lite.pm
MIME-Lite-3.01_05/lib/MIME/Lite.pm
--- MIME-Lite-3.01_05-vanilla/lib/MIME/Lite.pm 2005-12-09
21:55:03.000000000 +0100
+++ MIME-Lite-3.01_05/lib/MIME/Lite.pm 2006-04-06 16:36:22.000000000 +0200
@@ -1085,10 +1085,10 @@
if ( ( $ds_wanted or $ds_defaulted ) and !exists( $params{Date} ) ) {
# Updated to use local time and numeric offset per RFC 2822
# Calculate offset from UTC
- use Time::Local; # ships w/ Perl so should be OK to assume
presence
- my $t0 = timegm( 0, 0, 0, 2, 0, 70 ); # one day from epoch
- my $t1 = timelocal( 0, 0, 0, 2, 0, 70 );
- my $offset = $t0 - $t1;
+ use Time::Local; # ships with Perl, so should be OK to
assume presence
+ my $t0 = time(); # current time in UTC
+ my $t1 = timegm( localtime($t0) ); # calculate local time,
convert to time value in secs
+ my $offset = $t1 - $t0;
my $offset_hrs = int( $offset / 3600 );
my $offset_min = int( $offset / 60 ) - $offset_hrs * 60;
my $offset_str = sprintf "%+.2d%02d", $offset_hrs, $offset_min;
Apply this patch as follows:
wget .../MIME-Lite-3.01_05.tar.gz
wget .../MIME-Lite-3.01_05.bug_17319.Date_UTC_offset.patch
tar -xzf MIME-Lite-3.01_05.tar.gz
cd MIME-Lite-3.01_05/
patch -p1 < ../MIME-Lite-3.01_05.bug_17319.Date_UTC_offset.patch
I hope this is helpful to you,
RWF