| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Egg::View::Mail::MIME::Entity; |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# $Id: Entity.pm 285 2008-02-28 04:20:55Z lushe $ |
|
6
|
|
|
|
|
|
|
# |
|
7
|
2
|
|
|
2
|
|
774
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
82
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
74
|
|
|
9
|
2
|
|
|
2
|
|
3294
|
use MIME::Entity; |
|
|
2
|
|
|
|
|
274085
|
|
|
|
2
|
|
|
|
|
571
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub create_mail_body { |
|
14
|
0
|
|
|
0
|
1
|
|
my($self, $data)= @_; |
|
15
|
0
|
|
|
|
|
|
my $mime= do { |
|
16
|
0
|
|
|
|
|
|
my %attr; |
|
17
|
0
|
|
|
|
|
|
my $body= $self->__get_mailbody($data); |
|
18
|
0
|
0
|
|
|
|
|
if (my $headers= $data->{headers}) { %attr= %$headers } |
|
|
0
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
for ( [qw/ to To /], |
|
20
|
|
|
|
|
|
|
[qw/ from From /], |
|
21
|
|
|
|
|
|
|
[qw/ cc CC /], |
|
22
|
|
|
|
|
|
|
[qw/ bcc BCC /], |
|
23
|
|
|
|
|
|
|
[qw/ replay_to Reply-To /], |
|
24
|
|
|
|
|
|
|
[qw/ return_path Return-Path /], |
|
25
|
|
|
|
|
|
|
[qw/ subject Subject /], |
|
26
|
|
|
|
|
|
|
[qw/ x_mailer X-Mailer /] ) { |
|
27
|
0
|
0
|
|
|
|
|
$attr{$_->[1]}= $data->{$_->[0]} if $data->{$_->[0]}; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
0
|
|
|
|
|
|
MIME::Entity->build( %attr, Data=> [$$body] ); |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
0
|
0
|
|
|
|
|
if (my $attach= $data->{attach}) { |
|
32
|
0
|
|
|
|
|
|
eval{ |
|
33
|
0
|
0
|
|
|
|
|
if (ref($attach) eq 'HASH') { |
|
|
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$mime->attach(%$attach); |
|
35
|
|
|
|
|
|
|
} elsif (ref($attach) eq 'ARRAY') { |
|
36
|
0
|
|
|
|
|
|
$mime->attach(%$_) for @{$self->attach}; |
|
|
0
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
}; |
|
39
|
0
|
0
|
|
|
|
|
$@ and die $@; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
0
|
|
|
|
|
|
\$mime->stringify; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Egg::View::Mail::MIME::Entity - The content of the transmission of mail is made with MIMI::Entity. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
package MyApp::View::Mail::MyComp; |
|
55
|
|
|
|
|
|
|
use base qw/ Egg::View::Mail::Base /; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
........... |
|
58
|
|
|
|
|
|
|
..... |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__PACKAGE__->setup_mailer( CMD => 'MIME::Entity' ); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
It is MAIL component for the content of the transmission of mail to be made from |
|
65
|
|
|
|
|
|
|
L<MIMI::Entity>. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Use is enabled specifying 'MIME::Entity' for the second argument of 'setup_mailer' |
|
68
|
|
|
|
|
|
|
method. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__PACKAGE__->setup_mailer( SMTP => qw/ MIME::Entity / ); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 create_mail_body ([MAIL_DATA_HASH]) |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The result is returned by the SCALAR reference by processing MAIL_DATA_HASH with |
|
77
|
|
|
|
|
|
|
L<MIMI::Entity>. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
The following item comes to be evaluated by the argument and the configuration |
|
80
|
|
|
|
|
|
|
of 'send' method of L<Egg::View::Mail::Base>. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head3 headers |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The header that wants to be included in the content of mail can be passed with |
|
85
|
|
|
|
|
|
|
HASH. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
headers => { |
|
88
|
|
|
|
|
|
|
'X-Hoge' => 'fooo', |
|
89
|
|
|
|
|
|
|
}, |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head3 attach |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The attached file is put up by mail. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
attach => [ |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
|
|
|
|
|
|
Path => '/path/to/images/abc.gif', |
|
98
|
|
|
|
|
|
|
Type => 'image/gif', |
|
99
|
|
|
|
|
|
|
Encoding => 'Base64', |
|
100
|
|
|
|
|
|
|
}, |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
|
|
|
|
|
|
Path => '/path/to/content/abc.txt', |
|
103
|
|
|
|
|
|
|
Type => 'text/plain', |
|
104
|
|
|
|
|
|
|
}, |
|
105
|
|
|
|
|
|
|
], |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L<Egg::Release>, |
|
110
|
|
|
|
|
|
|
L<Egg::View::Mail>, |
|
111
|
|
|
|
|
|
|
L<Egg::View::Mail::Base>, |
|
112
|
|
|
|
|
|
|
L<MIME::Entity>, |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHOR |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>, All Rights Reserved. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
123
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
|
124
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
|
127
|
|
|
|
|
|
|
|