Re: Archive to Database

"Support" <[email protected]>
Newsgroups gmane.mail.qmail.scanner
Message-ID <[email protected]>
> Hello
>
> What the hell does it have to do with Qmail-Scanner ??
> Anyway, you should watch for "reformail" from the "maildrop" archive,
> then a 3-lines Perl script to feed your database.
>
> Bye
>
>
> Support a écrit :
>> Does anyone here know of a script to import the Archive Maildir into a
>> database?
>>
>> I have a situation where we need to quickly sort through  hundreds of
>> thousands of messages based on subject line, sender, recipient, and
>> message
>> text. We have used Evolution but after importing about three months of
>> mail
>> it does not perform well.
>>
>> I am trying to avoid re-inventing the wheel.
>>
>> Thanks!
>> Blaine
>>
>>
>> -------------------------------------------------------------------------
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to share
>> your
>> opinions on IT & business topics through brief surveys - and earn cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> _______________________________________________
>> Qmail-scanner-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/qmail-scanner-general
>>
>
>
The subroutine below is what my question has to do with Qmail-Scanner.
This is from QS1.25. What I would ultimately like to do is replace this
with a subroutine that would put the mail directly into a database instead
of the  Maidir.

sub cleanup {
  closelog();
  chdir("$scandir/");
  if ($archiveit !~ /^(1|yes)$/i) {
    #This will only archive mail where the sender or recipient matches the
regex that is $archiveit
    if ($headers{'MAILFROM'} !~ /$archiveit/i && $headers{'RCPTTO'} !~
/$archiveit/i) {
      $archiveit=0;
    }
  }
  if (!$archiveit) {
    &debug("cleanup: $rm_binary -rf $ENV{'TMPDIR'}/
$scandir/$wmaildir/new/$file_id") ;
  } else {
    # check if $archivedir exists
    if (! -d "$scandir/$archivedir") {
      mkdir("$scandir/$archivedir",0700) || &error_condition("cannot
create $scandir/$archivedir - $!");
      mkdir("$scandir/$archivedir/new",0700) || &error_condition("cannot
create $scandir/$archivedir/new - $!");
      mkdir("$scandir/$archivedir/cur",0700) || &error_condition("cannot
create $scandir/$archivedir/cur - $!");
      mkdir("$scandir/$archivedir/tmp",0700) || &error_condition("cannot
create $scandir/$archivedir/tmp - $!");
    }
    if ( -f "$scandir/$wmaildir/new/$file_id" ) {
      &debug("cleanup: archiving into $scandir/$archivedir/new/");
      &minidebug("cleanup: archiving into $scandir/$archivedir/new/");
      rename("$scandir/$wmaildir/new/$file_id","$scandir/$archivedir/new/$file_id");
      #This will do for now. Not pretty - but very cheap!
      #We need to append this information, otherwise how do you know who
this message
      #was from or to?
      #
      open(ARCHIVE,">>$scandir/$archivedir/new/$file_id");
      print ARCHIVE "\n*** Qmail-Scanner Envelope Details Begin ***\n";
      print ARCHIVE "${V_HEADER}-Mail-From: \"$returnpath\" via $hostname\n";
      print ARCHIVE "${V_HEADER}-Rcpt-To: \"$recips\"\n";
      print ARCHIVE "$V_HEADER: $VERSION ($SCANINFO  Clear:$tag_score.
Processed in ",tv_interval($start_time,[gettimeofday])," secs)\n";
      if (($quarantine_description =~ /spam/i) && $sa_report) {
        print ARCHIVE "SA_REPORT hits =
$sa_hits/$required_hits\n$sa_report\n";
      }
      print ARCHIVE "*** Qmail-Scanner Envelope Details End ***\n";
      close ARCHIVE;
    }
  }
  system("$rm_binary -rf $ENV{'TMPDIR'}/ $scandir/$wmaildir/new/$file_id")
if ($DEBUG < 100 && $file_id ne "");

}




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.