procmail
[Top] [All Lists]

Re: ideas on splitting mail saved by Outlook to IMAP folder

2006-05-29 07:25:32
Hi there,

On Mon, 29 May 2006 Gary Funck wrote:

... the problem that arises is that both the archived mailbox and
the truncated mailbox have extraneous '>' characters placed in front of
valid From_ lines.  This happens because Outlook in its wisdom...

I ran into similar problems when I had to migrate a client's mailboxes
from a Windup box running some well-dodgy software called 'Interchange'
to a Linux/sendmail box serving about 25 Windoze Thunderbird clients.
(Interchange had been sending the same half-dozen five-megabyte messages
to the same couple of dozen recipients every 20 minutes for two years.:)

The issue was to change the text in the Interchange server files into
something which could easily be converted to mbox format by formail.
On its own formail couldn't quite do it, but on scanning the formail
output it was pretty easy to see what was going wrong and knock up a
Perl front end to fix the bits that were throwing formail before the
text was processed.

FWIW the scripts are below.  This was a long time ago, so don't ask me
to remember every little detail.  I've added some comments and tweaked
the indentation but it should still run out of the box.  Of course it's
no use to anyone out of the box and TMTOWTDI.

HTH.

73,
Ged.

======================================================================
#!/bin/sh
# list.sh

# Reads a bunch of files in directories in the directory SMTP, hands
# them to convert.pl, puts the output files into the directory MBOX.

for directoryname in SMTP/*
  do
  for filename in $directoryname/*.MSG
    do
    perl -w convert.pl $filename | formail -d -s >>$directoryname.mbox
  done
  mv $directoryname.mbox MBOX
done

# EOF: list.sh
======================================================================
#!/usr/bin/perl
# convert.pl

# Reads stdin, does some minor editing, outputs to stdout.

my $line_is_not_empty = 1;
while(<>)                                   # Read the input line-by-line
{
    my $line = $_;
    if( $line =~ m/^XXXXXXXXXXXXXXXXXX / )  # Ignore silly lines
    {
      next;
     }
    $line .= "\n";                          # Add newline
    $line =~ s/\r//;                        # Remove any carriage return
    $line =~ s/\n\n/\n/;                    # Remove duplicate newlines
    if( $line =~ m/^\n$/s )                 # Clear the flag if line empty
    {
      $line_is_not_empty = 0;
    }
    else
    {
      $line_is_not_empty = 1;
    }
    print $line;                            # Output the line
}
if( $line_is_not_empty ) { print "\n"; }    # Add a newline if flag set

# EOF: convert.pl
======================================================================

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail