USM Bish wrote:

> To  convert a mbox to MH type folder, copy the mbox file back
> to the spool, and use "inc" to place them into  the mail dir.
> inc is in the mh/ nmh packages. Alternatively use sylpheed to
> get the mail to your mail dir. viz:    
> 
>   $cp mbox /var/spool/mail/user   # (replace with user name)
>   $inc
>         


Qmail's Maildir format is like this : Under your home directory there 
should be a directory Maildir (or whatever Qmail has been told the 
maildir format directory is). Beneath that are three directories cur, 
new and tmp. All emails first go into tmp and once the file has been 
created successfully it is moved to new - if the save on server option 
is exercised while checking emails then the files are moved to cur once 
they have been retrieved.

Now the filenames is in this format <epoch time>.<process id>.<hostname> 
  (The naming convention doesnt actually matter as long as they are 
unique qmail-pop3d will read it). Each file contains the complete email 
with it's headers as it was transferred through the network - qmail 
would add a extra header line Delivered-To: which is useful in keeping 
track of trapping double bounces.

> The reverse is not easy because once alls the mails have been
> split into files, joining them back does not form a mbox type
> file. I use a self-written script for that purpose. It is for
> download at http://geocities.com/usmbish/mh2mbox-0.2.tar.gz.
> 
> Note: mailers like netscape-communicator use their own format
> and is neither mbox or MH type.


Pine mbox uses a line with the following format for separator :
------------
<new line>
 From <userid> <day mon dt hh:mm:ss year>
------------
I cant be sure but the userid will probably be "-" if the email is not 
from the localhost.

I am not sure why Bish faced a problem with Netscape Mail but I used the 
following script to extract 4507 emails from the Netscape 4.78 (Windows) 
Mail - the only thing I had to do was to use dos2unix for the newline 
character.

-------------------------------------------------------------
#!/usr/local/bin/perl -w
#
# mbox2maildir: coverts mbox file to maildir directory - the reverse of
# maildir2mbox from the qmail distribution.
#
# Usage: mbox2maildir uses the same environment variables as maildir2mbox:
# MAILDIR is the name of your maildir directory; MAIL is the name of your
# mbox file; MAILTMP is ignored.
#
# WARNING: there is no locking; don't run more than one of these!  you
# have been warned.
#
# based on convert-and-create by Russell Nelson <[EMAIL PROTECTED]>
# kludged into this by Ivan Kohler <[EMAIL PROTECTED]> 97-sep-17
# Further modified by Mithun Bhattacharya <[EMAIL PROTECTED]> 4 Dec 
2001

$spoolname = "$ENV{MAILDIR}";
-d $spoolname or mkdir $spoolname,0700
   or die("fatal: $spoolname doesn't exist and can't be created.\n");

chdir($spoolname) or die("fatal: unable to chdir to $spoolname.\n");
-d "tmp" or mkdir("tmp",0700) or die("fatal: unable to make tmp/ subdir\n");
-d "new" or mkdir("new",0700) or die("fatal: unable to make new/ subdir\n");
-d "cur" or mkdir("cur",0700) or die("fatal: unable to make cur/ subdir\n");

open(SPOOL, "<$ENV{MAIL}")
   or die "$! $ENV{MAIL}\n";
$count = 1;
$i = time;
while(<SPOOL>) {
   if (/^From /) {
     $fn = sprintf("new/%d.$$.mbox", $i);
     open(OUT, ">$fn") or die("fatal: unable to create new message");
     print STDERR "$count: $fn\n";
     $count++;
     $i++;
     next;
   }
   s/^>From /From /;
   print OUT or die("$! " . $ENV{MAIL} . "/$fn\n");
}
close(SPOOL);
close(OUT);


_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help

Reply via email to