I am new to Cyrus and have been looking at mailbox conversion using the
inboxfer script as described in the O'Reilly "Managing IMAP" book.  When I
came across the problem with Outlook Express displaying the wrong Received
dates I looked in the mailing list archive.  I came across the discussion
of the same problem but with regard to the use of imapmigrate.

The patch which was posted by Eric Sorenson led me to look at the code of
reconstruct.c...

        /* Message file write time is good estimate of internaldate */
        message_index.internaldate = sbuf.st_mtime;

My solution to the problem was to change the cpmsg Perl script which is
used by both inboxfer and folderxfer to process the Unix From line at the
beginning of the message to obtain the sender and the Received date/time.
It replaces it with a Return-Path: field and uses the Received date/time
to set the atime and mtime of the resulting file.  The relevant bits of
code are appended.

I would welcome any comments, especially if what I am doing is not a good
idea for some reason!

Richard
--
Richard Gilbert
Corporate Information and Computing Services
University of Sheffield, Sheffield, S10 2TN, UK
Phone: +44 114 222 3028   Fax: +44 114 222 3040


%month_num = ( Jan => 0, Feb => 1, Mar => 2, Apr => 3, May => 4, Jun => 5,
               Jul => 6, Aug => 7, Sep => 8, Oct => 9, Nov =>10, Dec =>11 );

   :
   :

# Process the Unix From line to extract the sender and the
# received date/time and replace it with a Return-Path: header.
# Leave it alone if it is not quite what we are expecting.

chomp($_ = <STDIN>);
if (/^From /) {
   ($From,$sender,$weekday,$month,$day,$time,$year) = split(/ +/);
   if ($time =~ /^\d{2}:\d{2}:\d{2}$/ &&  # Sanity checks
       defined $month_num{$month} &&
       $year =~ /^(?:19|20)\d{2}$/) {
      ($hour,$min,$sec) = split(/:/,$time);
      use Time::Local;
      $received_time = timelocal($sec,$min,$hour,$day,$month_num{$month},$year-1900);
      $_ = "Return-Path: <$sender>";
   }
}
print OUTFILE "$_\015\012";

while (<STDIN>) {
   chomp;
   print OUTFILE "$_\015\012";  # Add CRLF to each line!
}
close OUTFILE;

utime($received_time,$received_time,$filename) if $received_time;





Reply via email to