#!/usr/bin/perl -w
#
# allmailscan.pl  --crb3 15jan01/26feb01/02jan02/19may03
# program copyright (C) 2001-2003 C. R. Bryan III
# <crb3@stormbringer.org> All Rights Reserved, released
# under the terms of version 2 of the GNU General Public License.
#
# v0.03: 19may03: backport commandline options from the C port
#
use Cwd;

$fromlen = 40;

$first=1;
$doall=0;
$basedir="/home";
$subdir="new";
while(defined($ARGV[0])){
  if(substr($ARGV[0],0,1eq '-'){
    $arg=$v=shift(@ARGV);
    $key=lc(substr($v,1,1));
    substr($v,0,2)="";
    if($key eq "a"){                            # handle toggle args first
      $doall ^= 1;                              #  -a: do em all
      next;
    }elsif($key eq "h"){                        #  -h: help screen and byebye
      print "$0 [options]\n  -a\t\tshow all users\n"
            ."  -b <basedir>\tdefault: /home\n"
            ."  -m <maildir>\tdefault: /new\n"
            ."  -h\t\tshow these helps\n";
      exit(0);
    }
    substr($v,0,1)="" if index($v,'=')==0;      # set up arg
    $v=shift(@ARGVif length($v)==0;
    if($key eq "b"){                            # use a different basedir
      $basedir=$v;
    }elsif($key eq "m"){                        # use a different maildir
      $subdir=$v;
    }else{
      die "$0$arg option not recognized\n";
    }
  }else{                                # no non-switch args for this pgm
    die "$0$arg command not recognized\n";
  }
}


print uc($subdir)." MAIL SUMMARY\n";
chdir $basedir;
$dir = cwd();
for( <*> ) {
  if-d ) {
    $maildir = "$basedir/$_/Maildir/$subdir";
    $name=$_;
    if-d $maildir ){
      print "$name:\n" if $doall;
      chdir $maildir;
      $first=1;
      for( <*> ) {
        if-f ){
          if($first==1 and !$doall){
            print "$name:\n";
            $first=0;
          }
          $infile = $_;
          open(IFIL,"<$infile"or warn "can't open $infile\n";
          $inline = "\n";
          $from = $subj = "<*>"$gotf=$gots=0;
          while(defined($inline=<IFIL>and !($inline =~ /^\s*\n$/ or ($gotf and $gots))){
            chomp $inline;
            $inline =~ s/^\s+//;
            next unless index($inline,':')>-1;
            ($hed,$arg)=split(/\:\s+/,$inline,2);
            $hed=lc($hed);
            if($hed eq "from"){
              $from=substr($arg,0,$fromlen);            # truncating
              $from .= (' ' x ($fromlen-length($arg)))  # padding
                  if length($arg)<$fromlen;
              $from .=":  "$gotf=1;
            }elsif($hed eq "subject"){
              $subj=$arg$gots=1;
            }
          }
          print "  $from$subj\n" if defined($from);
          close(IFIL);
        }
      }

      chdir $dir;

    }
  }
}

Grab a
gzipped
copy
here
 
Syntax highlighting using Syntax::Highlight::Engine::Kate