line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Egg::View::Mail::Plugin::EmbAgent; |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# $Id: EmbAgent.pm 332 2008-04-19 17:03:10Z lushe $ |
6
|
|
|
|
|
|
|
# |
7
|
2
|
|
|
2
|
|
611
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
73
|
|
8
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
681
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub __get_mailbody { |
13
|
0
|
|
|
0
|
|
|
my($self, $data)= @_; |
14
|
0
|
0
|
0
|
|
|
|
return $self->next::method($data) |
15
|
|
|
|
|
|
|
if ($data->{no_embagent} or ! $data->{body}); |
16
|
0
|
|
|
|
|
|
my $req = $self->e->request; |
17
|
0
|
|
|
|
|
|
my $ipaddr= $req->address; |
18
|
0
|
|
0
|
|
|
|
my $regex = $data->{no_embagent_ip_regex} |
19
|
|
|
|
|
|
|
|| qr{^(?:192\.168\.|127\.0\.0\.1)}; |
20
|
0
|
0
|
|
|
|
|
return $self->next::method($data) if $ipaddr=~m{$regex}; |
21
|
0
|
|
|
|
|
|
my $body= $data->{body}= $self->__init_mailbody($data); |
22
|
0
|
|
|
|
|
|
$$body.= <<END_AGENT; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
---------------------------------------------------------------------- |
26
|
|
|
|
|
|
|
END_AGENT |
27
|
0
|
0
|
|
|
|
|
if ($data->{embagent_remote_host}) { |
28
|
0
|
|
|
|
|
|
$$body.= <<END_AGENT; |
29
|
0
|
|
|
|
|
|
REMOTE_HOST : @{[ $req->remote_host ]} |
30
|
|
|
|
|
|
|
END_AGENT |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
$$body.= <<END_AGENT; |
33
|
0
|
|
|
|
|
|
REMOTE_ADDR : @{[ $req->address ]} |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
USER_AGENT : @{[ $req->agent ]} |
35
|
|
|
|
|
|
|
---------------------------------------------------------------------- |
36
|
|
|
|
|
|
|
END_AGENT |
37
|
0
|
|
|
|
|
|
$self->next::method($data); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Egg::View::Mail::Plugin::EmbAgent - Client information is put on the content of mail. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOPSIS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
package MyApp::View::Mail::MyComp; |
51
|
|
|
|
|
|
|
use base qw/ Egg::View::Mail::Base /; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
........... |
54
|
|
|
|
|
|
|
..... |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__PACKAGE__->setup_plugin('EmbAgent'); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Information on the access to the content of mail is put. It is MAIL plugin. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
When 'EmbAgent' is passed to 'setup_plugin' method, it is built in. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
There is a thing that how of information to stick changes when using it with |
65
|
|
|
|
|
|
|
other components that use '__get_mailbody' and adjust the built-in order, please. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__PACKAGE__->setup_plugin(qw/ |
68
|
|
|
|
|
|
|
Signature |
69
|
|
|
|
|
|
|
EmbAgent |
70
|
|
|
|
|
|
|
/); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The following items come to be evaluated by 'send' method of L<Egg::View::Mail::Base> |
73
|
|
|
|
|
|
|
when building it in. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head3 no_embagent |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
When an effective value is set, putting client information is canceled. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$mail->send( |
80
|
|
|
|
|
|
|
body => ....., |
81
|
|
|
|
|
|
|
no_embagent => 1, |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 embagent_remote_host |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Information on REMOTE_HOST also sticks when an effective value is set. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$mail->send( |
89
|
|
|
|
|
|
|
body => ....., |
90
|
|
|
|
|
|
|
embagent_remote_host => 1, |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Setting it in the configuration is good to always put up REMOTE_HOST. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SEE ALSO |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
L<Egg::Release>, |
98
|
|
|
|
|
|
|
L<Egg::View::Mail>, |
99
|
|
|
|
|
|
|
L<Egg::View::Mail::Base>, |
100
|
|
|
|
|
|
|
L<Egg::Request>, |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>, All Rights Reserved. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
111
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
112
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|