| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mail::Action; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
52
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
43
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use vars '$VERSION'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
73
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.46'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp 'croak'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
83
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
900
|
use Mail::Mailer; |
|
|
1
|
|
|
|
|
18687
|
|
|
|
1
|
|
|
|
|
9
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
696
|
use Mail::Action::Request; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
32
|
|
|
14
|
1
|
|
|
1
|
|
535
|
use Mail::Action::PodToHelp; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
1089
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new |
|
17
|
|
|
|
|
|
|
{ |
|
18
|
21
|
|
|
21
|
1
|
92
|
my ($class, $address_dir, @options, %options, $fh) = @_; |
|
19
|
21
|
100
|
|
|
|
85
|
croak "No address directory provided\n" unless $address_dir; |
|
20
|
|
|
|
|
|
|
|
|
21
|
20
|
100
|
|
|
|
53
|
if (@options == 1) |
|
22
|
|
|
|
|
|
|
{ |
|
23
|
2
|
|
|
|
|
4
|
$fh = $options[0]; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
else |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
18
|
100
|
|
|
|
88
|
%options = @options if @options; |
|
28
|
18
|
100
|
|
|
|
68
|
$fh = $options{Filehandle} if exists $options{Filehandle}; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
20
|
|
|
|
|
94
|
my $storage = $class->storage_class(); |
|
32
|
|
|
|
|
|
|
|
|
33
|
20
|
100
|
|
|
|
66
|
unless ($options{Request}) |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
8
|
|
100
|
|
|
31
|
$fh ||= \*STDIN; |
|
36
|
8
|
100
|
|
|
|
61
|
$fh = do { local $/; <$fh> } if defined( fileno( $fh ) ); |
|
|
3
|
|
|
|
|
17
|
|
|
|
3
|
|
|
|
|
94
|
|
|
37
|
8
|
|
|
|
|
48
|
$options{Request} = Mail::Action::Request->new( $fh ); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
20
|
|
100
|
|
|
103
|
$options{Storage} ||= $options{Addresses}; |
|
41
|
20
|
100
|
|
|
|
122
|
$options{Storage} = $storage->new($address_dir) unless $options{Storage}; |
|
42
|
|
|
|
|
|
|
|
|
43
|
20
|
|
|
|
|
146
|
bless \%options, $class; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub storage |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
7
|
|
|
7
|
1
|
15
|
my $self = shift; |
|
49
|
7
|
|
|
|
|
34
|
$self->{Storage}; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub request |
|
53
|
|
|
|
|
|
|
{ |
|
54
|
24
|
|
|
24
|
1
|
44
|
my $self = shift; |
|
55
|
24
|
|
|
|
|
109
|
$self->{Request}; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# try to avoid this one from now on |
|
59
|
|
|
|
|
|
|
sub message |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
8
|
|
|
8
|
1
|
20
|
my $self = shift; |
|
62
|
8
|
|
|
|
|
30
|
my $request = $self->request(); |
|
63
|
8
|
|
|
|
|
31
|
$request->message(); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub fetch_address |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
|
69
|
3
|
|
|
|
|
12
|
my $alias = $self->parse_alias( $self->request->recipient() ); |
|
70
|
3
|
|
|
|
|
20
|
my $addresses = $self->storage(); |
|
71
|
|
|
|
|
|
|
|
|
72
|
3
|
100
|
|
|
|
31
|
return unless $addresses->exists( $alias ); |
|
73
|
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
174
|
my $addy = $addresses->fetch( $alias ); |
|
75
|
|
|
|
|
|
|
|
|
76
|
2
|
100
|
|
|
|
154
|
return wantarray ? ( $addy, $alias ) : $addy; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub command_help |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
1
|
|
|
1
|
1
|
4
|
my ($self, $pod, @headings) = @_; |
|
82
|
1
|
|
|
|
|
4
|
my $request = $self->request(); |
|
83
|
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
5
|
my $from = $request->header( 'From' )->address(); |
|
85
|
1
|
|
|
|
|
20
|
my $parser = Mail::Action::PodToHelp->new(); |
|
86
|
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
166
|
$parser->show_headings( @headings ); |
|
88
|
1
|
|
|
|
|
161
|
$parser->output_string( \( my $output )); |
|
89
|
1
|
|
|
|
|
1965
|
$parser->parse_string_document( $pod ); |
|
90
|
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
352
|
$output =~ s/(\A\s+|\s+\Z)//g; |
|
92
|
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
21
|
$self->reply({ |
|
94
|
|
|
|
|
|
|
To => $from, |
|
95
|
|
|
|
|
|
|
Subject => ref( $self ) . ' Help' |
|
96
|
|
|
|
|
|
|
}, $output ); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub process_body |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
2
|
|
|
2
|
1
|
6
|
my ($self, $address) = @_; |
|
102
|
2
|
|
|
|
|
27
|
my $attributes = $address->attributes(); |
|
103
|
2
|
|
|
|
|
182
|
my $body = $self->request->remove_sig(); |
|
104
|
|
|
|
|
|
|
|
|
105
|
2
|
|
100
|
|
|
26
|
while (@$body and $body->[0] =~ /^(\w+):\s*(.*)$/) |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
3
|
|
|
|
|
11
|
my ($directive, $value) = (lc( $1 ), $2); |
|
108
|
3
|
100
|
|
|
|
29
|
$address->$directive( $value ) if exists $attributes->{ $directive }; |
|
109
|
3
|
|
|
|
|
134
|
shift @$body; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
2
|
|
|
|
|
17
|
return $body; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub reply |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
2
|
|
|
2
|
1
|
9
|
my ($self, $headers, @body) = @_; |
|
118
|
|
|
|
|
|
|
|
|
119
|
2
|
|
|
|
|
36
|
my $mailer = Mail::Mailer->new(); |
|
120
|
2
|
|
|
|
|
42
|
$mailer->open( $headers ); |
|
121
|
2
|
|
|
|
|
217
|
$mailer->print( @body ); |
|
122
|
2
|
|
|
|
|
145
|
$mailer->close(); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub find_command |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
4
|
|
|
4
|
1
|
7
|
my $self = shift; |
|
128
|
4
|
|
|
|
|
15
|
my ($subject) = $self->request()->header( 'Subject' ) =~ /^\*(\w+)\*/; |
|
129
|
|
|
|
|
|
|
|
|
130
|
4
|
100
|
|
|
|
17
|
return unless $subject; |
|
131
|
|
|
|
|
|
|
|
|
132
|
3
|
|
|
|
|
10
|
my $command = 'command_' . lc $subject; |
|
133
|
3
|
100
|
|
|
|
42
|
return $self->can( $command ) ? $command : ''; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub copy_headers |
|
137
|
|
|
|
|
|
|
{ |
|
138
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
139
|
1
|
|
|
|
|
5
|
my $headers = $self->request()->headers(); |
|
140
|
|
|
|
|
|
|
|
|
141
|
1
|
|
|
|
|
2
|
my %copy; |
|
142
|
|
|
|
|
|
|
|
|
143
|
1
|
|
|
|
|
9
|
while (my ($header, $value) = each %$headers) |
|
144
|
|
|
|
|
|
|
{ |
|
145
|
7
|
100
|
|
|
|
17
|
next if $header eq 'From '; |
|
146
|
6
|
|
|
|
|
27
|
$copy{ $header } = join(', ', @$value ); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
5
|
return \%copy; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
|
153
|
|
|
|
|
|
|
__END__ |