Line # Revision Author
1 19 dpavlin #!/usr/bin/perl -w
2 #
3 # 2003-04-09 Dobrica Pavlinusic <dpavlin@pliva.hr>
4 #
5 # take a directory of inboxes and re-mail them through sendmail
6 # (to check for viruses, expand aliases/forwards etc etc)
7 #
8
9 $|=1;
10
11 #my @dir = ( '/var/mail' );
12 my @dir = ( '/home/dpavlin/x/mail' );
13
14 #my $sendmail = "| cat >> /tmp/sendmail";
15 my $sendmail = "| /usr/sbin/sendmail -t";
16
17 use File::Find;
18 find(\&remail, @dir);
19 sub remail {
20 return if (! -r $_ || -z $_ || m/^\./);
21 my $inbox = $_;
22 print "inbox: $_ ";
23 open(INBOX,$_) || warn "can't open inbox $_: $!";
24
25 my $mails = 0;
26
27 open(SENDMAIL, $sendmail) || die "sendmail: $!";
28 while(<INBOX>) {
29 if (/^From /) {
30 close(SENDMAIL);
31 open(SENDMAIL, $sendmail) || die "sendmail: $!";
32 $mails++;
33 print ".";
34 }
35 print SENDMAIL $_;
36 }
37 close(SENDMAIL);
38
39 print " $mails mails\n";
40 }
41