line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::MIME::MobileJP::Creator; |
2
|
2
|
|
|
2
|
|
15381
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
62
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
39
|
|
4
|
2
|
|
|
2
|
|
6
|
use utf8; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1091
|
use Email::MIME; |
|
2
|
|
|
|
|
107572
|
|
|
2
|
|
|
|
|
67
|
|
7
|
2
|
|
|
2
|
|
2452
|
use Email::Address::JP::Mobile; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Email::Address::Loose -override; |
9
|
|
|
|
|
|
|
use Carp (); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
my ($class, $to) = @_; |
13
|
|
|
|
|
|
|
Carp::croak("missing To") unless defined $to; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $mail = Email::MIME->create(); |
16
|
|
|
|
|
|
|
my $carrier = Email::Address::JP::Mobile->new($to); |
17
|
|
|
|
|
|
|
my $self = bless { mail => $mail, carrier => $carrier }, $class; |
18
|
|
|
|
|
|
|
if ($to) { |
19
|
|
|
|
|
|
|
$self->header('To' => $to); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
$self->mail->charset_set($carrier->send_encoding->mime_name); |
22
|
|
|
|
|
|
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub mail { $_[0]->{mail} } |
26
|
|
|
|
|
|
|
sub carrier { $_[0]->{carrier} } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub subject { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
$self->header('Subject' => @_); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub body { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
if (@_==0) { |
37
|
|
|
|
|
|
|
$self->carrier->send_encoding->decode($self->mail->body_raw()); |
38
|
|
|
|
|
|
|
} else { |
39
|
|
|
|
|
|
|
$self->mail->body_set($self->carrier->send_encoding->encode(@_)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub header { |
44
|
|
|
|
|
|
|
my ($self, $k, $v) = @_; |
45
|
|
|
|
|
|
|
if (defined $v) { |
46
|
|
|
|
|
|
|
$self->mail->header_set($k, $self->carrier->mime_encoding->encode($v)); |
47
|
|
|
|
|
|
|
} else { |
48
|
|
|
|
|
|
|
$self->carrier->mime_encoding->decode($self->mail->header_obj->header_raw($k)); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub add_part { |
53
|
|
|
|
|
|
|
my ($self, $body, $attributes) = @_; |
54
|
|
|
|
|
|
|
my $part = Email::MIME->create( |
55
|
|
|
|
|
|
|
body => $body, |
56
|
|
|
|
|
|
|
attributes => $attributes, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
$self->mail->parts_add([$part]); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub add_text_part { |
62
|
|
|
|
|
|
|
my ($self, $body, $attributes) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $encoding = $self->carrier->send_encoding(); |
65
|
|
|
|
|
|
|
my $part = Email::MIME->create( |
66
|
|
|
|
|
|
|
body => $encoding->encode($body), |
67
|
|
|
|
|
|
|
attributes => { |
68
|
|
|
|
|
|
|
content_type => 'text/plain', |
69
|
|
|
|
|
|
|
charset => $encoding->mime_name(), |
70
|
|
|
|
|
|
|
encoding => '7bit', |
71
|
|
|
|
|
|
|
%{ $attributes || +{} } |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
$self->mail->parts_add([$part]); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub finalize { |
78
|
|
|
|
|
|
|
my ($self) = @_; |
79
|
|
|
|
|
|
|
return $self->mail; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
__END__ |