/[perl]/mbox2sendmail.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /mbox2sendmail.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu May 8 15:58:07 2003 UTC (17 years, 2 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
re-mail inboxes through sendmail

1 dpavlin 1.1 #!/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    

  ViewVC Help
Powered by ViewVC 1.1.26