line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::JA::Mail;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.03'; # 2005-09-23 (since 2003-03-05)
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our @ISA = qw(Lingua::JA::Mail::Header);
|
6
|
1
|
|
|
1
|
|
30177
|
use Lingua::JA::Mail::Header;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
7
|
|
|
|
|
|
|
# When you `require' this base module for some reason,
|
8
|
|
|
|
|
|
|
# you had better specify absolute path to the module.
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
31
|
use 5.008;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
11
|
1
|
|
|
1
|
|
7
|
use strict;
|
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
34
|
|
12
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
13
|
1
|
|
|
1
|
|
7
|
use Carp;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
78
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
7
|
use Encode;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
453
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub body {
|
18
|
5
|
|
|
5
|
1
|
33
|
my($self, $string) = @_;
|
19
|
5
|
|
|
|
|
16
|
$$self{'body'} = $string;
|
20
|
5
|
|
|
|
|
12
|
return $self;
|
21
|
|
|
|
|
|
|
}
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub build {
|
24
|
5
|
|
|
5
|
1
|
9
|
my $self = shift;
|
25
|
5
|
|
|
|
|
27
|
my @key = $self->_header_order;
|
26
|
5
|
|
|
|
|
10
|
my @header;
|
27
|
5
|
|
|
|
|
10
|
foreach my $key (@key) {
|
28
|
33
|
100
|
|
|
|
66
|
unless ($key eq 'body') {
|
29
|
28
|
|
|
|
|
93
|
push(@header, "$key: $$self{$key}");
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
}
|
32
|
5
|
|
|
|
|
49
|
return join("\n", @header);
|
33
|
|
|
|
|
|
|
}
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub compose {
|
36
|
5
|
|
|
5
|
1
|
29
|
my $self = shift;
|
37
|
5
|
|
|
|
|
16
|
my $header = $self->build;
|
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
24
|
chomp(my $header2 = <<"EOF");
|
40
|
|
|
|
|
|
|
MIME-Version: 1.0
|
41
|
|
|
|
|
|
|
Content-Type: text/plain; charset=ISO-2022-JP
|
42
|
|
|
|
|
|
|
Content-Transfer-Encoding: 7bit
|
43
|
|
|
|
|
|
|
X-Mail-Composer: Mail.pm v$VERSION (Lingua::JA::Mail http://www.cpan.org/)
|
44
|
|
|
|
|
|
|
EOF
|
45
|
|
|
|
|
|
|
|
46
|
5
|
|
|
|
|
49
|
$header = join("\n", $header, $header2);
|
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
|
|
18
|
$self->_preconvert();
|
49
|
5
|
|
|
|
|
18
|
my $body = encode('iso-2022-jp', $$self{'body'});
|
50
|
|
|
|
|
|
|
|
51
|
5
|
|
|
|
|
461
|
return "$header\n\n$body";
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _preconvert {
|
55
|
5
|
|
|
5
|
|
7
|
my $self = shift;
|
56
|
|
|
|
|
|
|
|
57
|
5
|
|
|
|
|
26
|
utf8::decode(my $string = $$self{'body'});
|
58
|
1
|
|
|
1
|
|
6
|
$string =~ tr/\x{005C}\x{00A5}\x{2014}\x{203E}\x{2225}\x{FF0D}\x{FF5E}\x{FFE0}\x{FFE1}\x{FFE2}/\x{FF3C}\x{FFE5}\x{2015}\x{FFE3}\x{2016}\x{2212}\x{301C}\x{00A2}\x{00A3}\x{00AC}/;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
190
|
|
59
|
|
|
|
|
|
|
|
60
|
5
|
|
|
|
|
12
|
$$self{'body'} = $string;
|
61
|
|
|
|
|
|
|
|
62
|
5
|
|
|
|
|
11
|
return $self;
|
63
|
|
|
|
|
|
|
}
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub sendmail {
|
66
|
0
|
|
|
0
|
1
|
|
my($self, $sendmail) = @_;
|
67
|
0
|
0
|
|
|
|
|
unless ($sendmail) {
|
68
|
0
|
|
|
|
|
|
$sendmail = 'sendmail';
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $mail = $self->compose;
|
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
open(MAIL, "| $sendmail -t -i")
|
74
|
|
|
|
|
|
|
or croak "failed piping to $sendmail";
|
75
|
0
|
|
|
|
|
|
print MAIL $mail;
|
76
|
0
|
|
|
|
|
|
close MAIL;
|
77
|
0
|
|
|
|
|
|
return $self;
|
78
|
|
|
|
|
|
|
}
|
79
|
|
|
|
|
|
|
########################################################################
|
80
|
|
|
|
|
|
|
1;
|
81
|
|
|
|
|
|
|
__END__
|