I work for an ISP with our own propriatary SMTP Daemon, one night our Daemon crashed and stayed down for 2 hours, in the mean time sendmail came up, started processing all the messages and (not being able to send them) dumped them all to a dead.letter file (150 Mb).

Using the following script (wrote it in 10 mins Whoohoo!) we were able to extract all the messages, including bodyparts, and send them to our customers:

#!/usr/local/bin/perl -w use strict; $| = 1; my @Message; my $MsgId; my $Found; my $Number=0; while(<>) { if (/^Return-Path:/) { $Found=0; push @Message, $_; while(<>) { push @Message,$_; last if (($Found==1)&&(/^--$MsgId\S*--/)); if ((/internal id (\S+);/)&&($Found==0)) { $MsgId=$1; $Found=1; }; }; open FILE,">good/$MsgId.$Number.msg" or die "Error writing to $MsgId +.msg\n"; print FILE @Message; close FILE; @Message=""; $Number++; }; };
Edited by dws to add <code> tags

Replies are listed 'Best First'.
RE: Dead.lettered
by Simplicus (Monk) on Apr 20, 2000 at 20:45 UTC
    Ain't it fun? If I can figure out how to make it seem to take longer to fix some of my problems, I can spend more time on the golf course.
    This is a really cool CUFP!

    Simplicus