#!/usr/bin/perl #!/usr/local/bin/perl # you know, adjust this for wherever perl is! # # (c) 2001 Kim Holburn # You are free to use and redistribute this script # # This script takes a unix style mailbox and forwards each email on # to the email address specified in the command line. # It is for sysadmins who have someone move, and have their mail forwarded # but they have some mail that didn't get forwarded. # You probably have to be root to run it but I make no checks. sub fail_usage { local ($mess) = @_; if ($mess) { print STDERR "\n$0 Error : $mess \n\n"; } print STDERR "Usage : \n"; print STDERR "$0 [-d|--debug [-d|--debug]] \n"; print STDERR ' 'x length($0)," -u toaddress mailfile [mailfiles]\n"; print STDERR "$0 -h|-?|--help\n"; print STDERR " (You can't concatenate options like this -ddu)\n"; print STDERR " (Options must be separate like this -d -d -u)\n"; print STDERR "\n"; print STDERR <; $line=1; if (!/^From /) { die "bad mailbox format on mailbox\n"; } #{ # print "bad mailbox first line, skipping first letter\n"; # while (<>!~/^From /) ; # # if (!/^From /) { die "bad mailbox format on mailbox\n"; } #} if (!&check_from ($_)) { die "from=\"$from\", fline=\"$_\""; } if ($debug) { $SEND=STDOUT; } else { $SEND=SEND; } &sendit; while (<>) { $line++; if (!/^From /) { if ($debug != 1) { print $SEND $_; } next; } if (!&check_from ($_)) { if ($debug != 1) { print $SEND ">$_"; } next; } if (!$debug) { close $SEND; } &sendit; } if (!$debug) { close $SEND; }