1 |
#!/usr/bin/perl -w |
2 |
|
3 |
# |
4 |
# read mbox with error messages from mail server (like |
5 |
# Returned mail: Host unknown (Name server... |
6 |
# and dump e-mails which are returned so that they can be feeded |
7 |
# back to sendmail using |
8 |
# $ sendmail -t < mail.0 |
9 |
# |
10 |
|
11 |
my $b; |
12 |
|
13 |
my $nr=1; |
14 |
|
15 |
while(<>) { |
16 |
if (m,^Content-Type: message/rfc822,) { |
17 |
$foo=<>; |
18 |
while ($foo !~ m,^Return-Path,) { $foo=<>; }; |
19 |
if ($foo !~ m,^Return-Path: <MAILER-DAEMON>,) { |
20 |
open(M,"> mail.$nr") || die $!; |
21 |
print "$nr: $foo\n\t$b\n"; |
22 |
print M $foo; |
23 |
chomp $b; |
24 |
while($foo=<>) { |
25 |
last if ($foo=~m,^$b,); |
26 |
print M $foo; |
27 |
} |
28 |
close(M); |
29 |
$nr++; |
30 |
} |
31 |
} |
32 |
$b=$_; |
33 |
} |
34 |
|