| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MIME::Lite::TT::HTML::Japanese; |
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1859
|
use MIME::Lite; |
|
|
1
|
|
|
|
|
36641
|
|
|
|
1
|
|
|
|
|
34
|
|
|
5
|
1
|
|
|
1
|
|
212527
|
use Template; |
|
|
1
|
|
|
|
|
21177
|
|
|
|
1
|
|
|
|
|
26
|
|
|
6
|
1
|
|
|
1
|
|
745
|
use Jcode; |
|
|
1
|
|
|
|
|
783735
|
|
|
|
1
|
|
|
|
|
104
|
|
|
7
|
1
|
|
|
1
|
|
1082
|
use DateTime::Format::Mail; |
|
|
1
|
|
|
|
|
961801
|
|
|
|
1
|
|
|
|
|
53
|
|
|
8
|
1
|
|
|
1
|
|
13
|
use Carp; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
760
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
MIME::Lite::TT::HTML::Japanese - Create html mail with MIME::Lite and TT |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use MIME::Lite::TT::HTML::Japanese; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $msg = MIME::Lite::TT::HTML::Japanese->new( |
|
21
|
|
|
|
|
|
|
From => 'from@example.com', |
|
22
|
|
|
|
|
|
|
To => 'to@example.com', |
|
23
|
|
|
|
|
|
|
Subject => 'Subject', |
|
24
|
|
|
|
|
|
|
Template => { |
|
25
|
|
|
|
|
|
|
html => 'mail.html', |
|
26
|
|
|
|
|
|
|
text => 'mail.txt', |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
Icode => 'euc', # input code (Jcode Format) |
|
29
|
|
|
|
|
|
|
TmplIcode => 'jis', # Template input code (Optional) |
|
30
|
|
|
|
|
|
|
TmplOptions => \%options, |
|
31
|
|
|
|
|
|
|
TmplParams => \%params, |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$msg->send; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This module provide easy interface to make MIME::Lite object with html formatted mail. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 new |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return MIME::Lite object with Japanese html mail format. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
|
49
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
50
|
0
|
0
|
|
|
|
|
my $options = @_ > 1 ? {@_} : $_[0]; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $template = delete $options->{Template}; |
|
53
|
0
|
0
|
|
|
|
|
return croak "html template not defined" unless $template->{html}; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
$template->{text} = generate_text( $template->{html} ) |
|
56
|
|
|
|
|
|
|
unless $template->{text}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $icode = delete $options->{Icode}; |
|
59
|
0
|
|
|
|
|
|
my $tmpl_icode = delete $options->{TmplIcode}; |
|
60
|
0
|
|
|
|
|
|
my $tmpl_params = delete $options->{TmplParams}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $tt = Template->new( delete $options->{TmplOptions} ); |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $subject = encode_subject( delete $options->{Subject}, $icode ); |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $msg = MIME::Lite->new( |
|
67
|
|
|
|
|
|
|
%$options, |
|
68
|
|
|
|
|
|
|
Subject => $subject, |
|
69
|
|
|
|
|
|
|
Type => 'multipart/alternative', |
|
70
|
|
|
|
|
|
|
Date => DateTime::Format::Mail->format_datetime( |
|
71
|
|
|
|
|
|
|
DateTime->now->set_time_zone('Asia/Tokyo') |
|
72
|
|
|
|
|
|
|
), |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my ( $text, $html ); |
|
76
|
0
|
0
|
|
|
|
|
$tt->process( $template->{text}, $tmpl_params, \$text ) |
|
77
|
|
|
|
|
|
|
or croak $tt->error; |
|
78
|
0
|
0
|
|
|
|
|
$tt->process( $template->{html}, $tmpl_params, \$html ) |
|
79
|
|
|
|
|
|
|
or croak $tt->error; |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
0
|
|
|
|
$msg->attach( |
|
82
|
|
|
|
|
|
|
Type => 'text/plain; charset=iso-2022-jp', |
|
83
|
|
|
|
|
|
|
Data => encode_body( $text, $tmpl_icode || $icode ), |
|
84
|
|
|
|
|
|
|
Encoding => '7bit', |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
0
|
|
|
|
$msg->attach( |
|
88
|
|
|
|
|
|
|
Type => 'text/html; charset=iso-2022-jp', |
|
89
|
|
|
|
|
|
|
Data => encode_body( $html, $tmpl_icode || $icode ), |
|
90
|
|
|
|
|
|
|
Encoding => '7bit', |
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
$msg; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 encode_subject |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub encode_subject { |
|
101
|
0
|
|
|
0
|
1
|
|
my ( $subject, $icode ) = @_; |
|
102
|
0
|
|
|
|
|
|
$subject = remove_utf8_flag($subject); |
|
103
|
0
|
|
|
|
|
|
Jcode->new( $subject, $icode )->mime_encode; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 encode_body |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub encode_body { |
|
111
|
0
|
|
|
0
|
1
|
|
my ( $body, $icode ) = @_; |
|
112
|
0
|
|
|
|
|
|
my $str = remove_utf8_flag($body); |
|
113
|
0
|
|
|
|
|
|
Jcode->new( $str, $icode )->jis; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 generate_text |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub generate_text { |
|
121
|
0
|
|
|
0
|
1
|
|
my $str = shift; |
|
122
|
0
|
|
|
|
|
|
$str =~ s/<.*?>//gs; |
|
123
|
0
|
|
|
|
|
|
$str; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 remove_utf8_flag |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub remove_utf8_flag { |
|
131
|
0
|
|
|
0
|
1
|
|
pack 'C0A*', shift; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L, L, L |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 AUTHOR |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Daisuke Murase Etypester@cpan.orgE |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 LICENSE |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
|
145
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |