-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMailStat.pl
More file actions
executable file
·82 lines (70 loc) · 1.42 KB
/
Copy pathMailStat.pl
File metadata and controls
executable file
·82 lines (70 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/perl
use strict;
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
my $HOME="$ENV{HOME}";
print "Please enter the name of the Mbox you want to process (default: spam):\n";
my $mbox;
chomp($mbox = <STDIN>);
if($mbox){
print " opening $HOME/Mail/ . $mbox\n";
open (FILE, $HOME . '/Mail/' . $mbox);
} else {
print " opening $HOME/Mail/spam\n";
open (FILE, $HOME . '/Mail/spam');
}
my %HashFrom;
my %HashTo;
my %HashEnvTo;
sub AddTO($){
my $cur = shift;
#printf "Adding $cur to TO\n"; tests
++$HashTo{$cur};
}
sub AddFROM{
++$HashFrom{$_};
}
sub AddMailToHash{
my ($mailstring, %Hash) = @_ ;
if(/</)
{
my @words=split(/</,$mailstring);
my @mail=split(/>/,@words[1]);
#print "current: @mail[0]\n";
AddTO(trim(@mail[0]));
}
else
{
#print "New Mail : " . $mailstring . "\n";
my $s = substr($mailstring,4);
my @words=split(/,/,$s);
#print "** Adding: ";
foreach my $mailadd (@words)
{
#print " $mailadd ";
AddTO(trim($mailadd));
}
#print "\n";
}
}
while (<FILE>) {
chomp;
if(/^To:/ || /^Cc:/ || /^Bcc:/)
{
AddMailToHash($_,%HashTo);
}
}
close (FILE);
print "Processing Hash\n";
print "Size from : ". keys(%HashFrom) . "\n";
print "Size to : ". keys(%HashTo) . "\n";
print "Size env-to : ". keys(%HashEnvTo) . "\n";
for my $sender ( sort keys %HashTo ) {
print "$sender: $HashTo{$sender}\n";
}
exit;