-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmua.pl
executable file
·68 lines (62 loc) · 2.24 KB
/
mua.pl
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
#!/home/acme/perl-5.12.3/bin/perl
use strict;
use warnings;
use Email::Date;
use Email::Folder;
use 5.12.0;
my $folder = Email::Folder->new(shift) || die $!;
my %seen;
while ( my $message = $folder->next_message ) {
my $date = $message->header("Date");
my $time_piece = find_date($message);
next unless $time_piece->year == 2011;
my $from = $message->header("From");
my $message_id = $message->header("Message-Id");
next if $seen{$from}++;
my $ua = $message->header("User-Agent") || $message->header("X-Mailer");
my $short_ua;
if ( $ua && $ua =~ m{^([A-Za-z ]+[A-Za-z])} ) {
$short_ua = $1;
$short_ua = 'Thunderbird' if $short_ua eq 'Mozilla';
} elsif ( $message->header('To') eq '[email protected]' ) {
$short_ua = 'A Perl smoker';
} elsif ( $message->header('To') eq '[email protected]' ) {
$short_ua = 'perlthanks';
} elsif ( $message->header('To') eq '[email protected]' ) {
$short_ua = 'perlbug';
} elsif ( $message->header('From') eq
'Perl5 Bug Summary <[email protected]>' )
{
$short_ua = 'perlbug-summary';
} elsif ( $message->header('From') eq
'"CERT(R) Coordination Center" <[email protected]>' )
{
$short_ua = 'CERT';
} elsif ( $ua && $ua eq '/home/nicholas/bin/summary.pl' ) {
$short_ua = $ua;
} elsif ( $message_id =~ /mail\.gmail\.com/
|| $message->header('From') =~ /gmail/ )
{
$short_ua = 'Gmail';
} elsif ( $message_id =~ /phx\.gbl/ ) {
$short_ua = 'Hotmail';
} elsif ( $message_id =~ /blackberry/ ) {
$short_ua = 'Blackberry';
} elsif ( defined $message->header('X-MS-Has-Attach') ) {
$short_ua = 'Exchange';
} elsif ( $message->header('X-LinkedIn-Class') ) {
$short_ua = 'LinkedIn';
} elsif ( $message->header('X-X-Sender') ) {
$short_ua = 'Pine';
} elsif ( $message->header('Mime-Version') =~ /Apple/ ) {
$short_ua = 'Apple Mail';
} elsif ( $message->header('RT-Ticket') ) {
$short_ua = 'RT';
} elsif ( $message->header('NNTP-Posting-Host') ) {
$short_ua = 'Google Groups';
} else {
warn $message->as_string;
$short_ua = 'Unknown';
}
say $short_ua;
}