File Coverage

blib/lib/Egg/View/Mail/Plugin/Lot.pm
Criterion Covered Total %
statement 9 27 33.3
branch 0 8 0.0
condition 0 7 0.0
subroutine 3 6 50.0
pod 1 1 100.0
total 13 49 26.5


line stmt bran cond sub pod time code
1             package Egg::View::Mail::Plugin::Lot;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: Lot.pm 285 2008-02-28 04:20:55Z lushe $
6             #
7 2     2   588 use strict;
  2         4  
  2         62  
8 2     2   10 use warnings;
  2         3  
  2         58  
9 2     2   11 use Carp qw/ croak /;
  2         4  
  2         639  
10              
11             our $VERSION = '0.01';
12              
13             sub send {
14 0     0 1   my $self= shift;
15 0 0         my $attr= { %{$self->config},
  0 0          
16 0           %{ $_[0] ? ($_[1] ? {@_}: $_[0]) : croak q{I want mail data.} },
17             };
18 0   0       my $toadder= $attr->{to} || croak q{I want to address.};
19 0   0 0     my $start_hook= $attr->{start_hook} || sub {};
  0            
20 0   0 0     my $end_hook = $attr->{end_hook} || sub {};
  0            
21 0           my $count;
22 0 0         for (ref($toadder) eq 'ARRAY' ? @$toadder : $toadder) {
23 0           ++$count;
24 0           my %data= ( %$attr, to=> $_ );
25 0           $data{body}= $self->create_mail_body(\%data);
26 0           $start_hook->($count, \%data);
27 0           $self->mail_send(\%data);
28 0           $end_hook->($count, \%data);
29             }
30 0 0         $count || 0;
31             }
32              
33             1;
34              
35             __END__
36              
37             =head1 NAME
38              
39             Egg::View::Mail::Plugin::Lot - MAIL plugin that enables specification of two or more destinations.
40              
41             =head1 SYNOPSIS
42              
43             package MyApp::View::Mail::MyComp;
44             use base qw/ Egg::View::Mail::Base /;
45            
46             ...........
47             .....
48            
49             __PACKAGE__->setup_plugin('Lot');
50              
51             =head1 DESCRIPTION
52              
53             It is MAIL plugin that enables the specification of two or more destinations.
54              
55             When 'Lot' is passed to 'setup_plugin' method, it is built in.
56              
57             =head1 METHODS
58              
59             =head2 send
60              
61             Mail is transmitted.
62              
63             Two or more addresses can be passed to 'to'.
64              
65             $mail->send(
66             to => [qw/
67             hoge@mydomain
68             fooo@anydomain
69             .....
70             /],
71             body => $mail_body,
72             );
73              
74             'send' method of Egg::View::Mail::Base is Obarraided.
75              
76             =head1 SEE ALSO
77              
78             L<Egg::Release>,
79             L<Egg::View::Mail>,
80             L<Egg::View::Mail::Base>,
81              
82             =head1 AUTHOR
83              
84             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>, All Rights Reserved.
89              
90             This library is free software; you can redistribute it and/or modify
91             it under the same terms as Perl itself, either Perl version 5.8.6 or,
92             at your option, any later version of Perl 5 you may have available.
93              
94             =cut
95