Hi,

I hacked this together tonight.  It's a perl program that filters the
procmail log file (if you have one and if you are running procmail).

I usually run it in a transparent Eterm above my mailbox to see mail
as it comes in.

The regexps and assignment is pretty ugly, but it works.  If anyone
wants to play around with it...


#!/usr/bin/perl
#
# Reads a mail log and prints a human readable output of 
# incoming and outgoing mails.
#
# Created  20001213 by Rob Hudson
# Modified 20010101 : Changed status output
use IO::File;

my $maillog = "/home/rob/.procmail/log";
my $sleeptime = 5;
my ($from, $date, $subject, $folder, $nextline);

open (ML, $maillog) or die "Can't open $maillog: $!";
seek (ML, -10240, SEEK_END);

format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<  
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$from, $folder, $subject
.

for (;;) {
  while (<ML>) {
    unless (/^From/) { next; } # Find the first line that starts with 'From'
    /^From (.[^\s]*) (.*)$/;
    $from = "From: $1";
    $date = $2;
    $nextline = <ML>;
    chomp $nextline;
    $nextline =~ /Subject: (.*)/;
    $subject = $1;
    my $nextline = <ML>;
    $nextline =~ /Folder: (.[^\s]*)/;
    $folder = "-> $1";

    write;
  }
  sleep $sleeptime;
  ML->clearerr();
}

Reply via email to