| 1 | package Lingua::JA::Mail; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | our $VERSION = '0.03'; # 2005-09-23 (since 2003-03-05) | |||||||||
| 4 | |||||||||||
| 5 | 1 | our @ISA = qw(Lingua::JA::Mail::Header); | |||||||||
| 6 | 1 | ▶ | use Lingua::JA::Mail::Header; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | # When you `require' this base module for some reason, | ||||||||||
| 8 | # you had better specify absolute path to the module. | ||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use Encode; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 5 | ▶ | sub body { | ||||||||
|
Subroutine
body: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 18 | 5 | my($self, $string) = @_; | |||||||||
| 19 | 5 | $$self{'body'} = $string; | |||||||||
| 20 | 5 | return $self; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 5 | ▶ | sub build { | ||||||||
|
Subroutine
build: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 24 | 5 | my $self = shift; | |||||||||
| 25 | 5 | my @key = $self->_header_order; | |||||||||
| 26 | 5 | my @header; | |||||||||
| 27 | 5 | foreach my $key (@key) { | |||||||||
| 28 | 33 | ▶ | unless ($key eq 'body') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 28 | push(@header, "$key: $$self{$key}"); | |||||||||
| 30 | } | ||||||||||
| 31 | } | ||||||||||
| 32 | 5 | return join("\n", @header); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 5 | ▶ | sub compose { | ||||||||
|
Subroutine
compose: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | 5 | my $self = shift; | |||||||||
| 37 | 5 | my $header = $self->build; | |||||||||
| 38 | |||||||||||
| 39 | 5 | 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 | $header = join("\n", $header, $header2); | |||||||||
| 47 | |||||||||||
| 48 | 5 | $self->_preconvert(); | |||||||||
| 49 | 5 | my $body = encode('iso-2022-jp', $$self{'body'}); | |||||||||
| 50 | |||||||||||
| 51 | 5 | return "$header\n\n$body"; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 5 | ▶ | sub _preconvert { | ||||||||
|
Subroutine
_preconvert: called CC=1 SCAR=0.0
| |||||||||||
| 55 | 5 | my $self = shift; | |||||||||
| 56 | |||||||||||
| 57 | 5 | utf8::decode(my $string = $$self{'body'}); | |||||||||
| 58 | 5 | $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}/; | |||||||||
| 59 | |||||||||||
| 60 | 5 | $$self{'body'} = $string; | |||||||||
| 61 | |||||||||||
| 62 | 5 | return $self; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 0 | ▶ | sub sendmail { | ||||||||
|
Subroutine
sendmail: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 66 | 0 | my($self, $sendmail) = @_; | |||||||||
| 67 | 0 | ▶ | unless ($sendmail) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 0 | $sendmail = 'sendmail'; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 0 | my $mail = $self->compose; | |||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | open(MAIL, "| $sendmail -t -i") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | or croak "failed piping to $sendmail"; | ||||||||||
| 75 | 0 | print MAIL $mail; | |||||||||
| 76 | 0 | close MAIL; | |||||||||
| 77 | 0 | return $self; | |||||||||
| 78 | } | ||||||||||
| 79 | ######################################################################## | ||||||||||
| 80 | 1 | 1; | |||||||||
| 81 | __END__ | ||||||||||