File Coverage

blib/lib/Eve/Email.pm
Criterion Covered Total %
statement 26 26 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package Eve::Email;
2              
3 9     9   45 use parent qw(Eve::Class);
  9         17  
  9         65  
4              
5 9     9   516 use strict;
  9         16  
  9         323  
6 9     9   47 use warnings;
  9         22  
  9         285  
7              
8 9     9   16066 use Email::Sender::Simple qw(sendmail);
  9         1665127  
  9         91  
9 9     9   3040 use Email::Simple;
  9         19  
  9         235  
10 9     9   57 use Email::Simple::Creator;
  9         20  
  9         2237  
11              
12             =head1 NAME
13              
14             B - a wrapper for the C library.
15              
16             =head1 SYNOPSIS
17              
18             use Eve::Email;
19              
20             my $mailer = Eve::Email->new();
21              
22             $mailer->send(to => $address, subject => $subject, body => $body);
23              
24             =head2 Constructor arguments
25              
26             =over 4
27              
28             =item C
29              
30             The from address line that will be added to each sent email.
31              
32             =back
33              
34             =head1 METHODS
35              
36             =head2 B
37              
38             =cut
39              
40             sub init {
41 1     1 1 6 my ($self, %arg_hash) = @_;
42 1         7 Eve::Support::arguments(\%arg_hash, my ($from));
43              
44 1         56 $self->{'_from'} = $from;
45              
46 1         5 return;
47             }
48              
49             =head2 B
50              
51             Send an email body with a certain subject to a certain recipient.
52              
53             =head3 Arguments
54              
55             =over 4
56              
57             =item C
58              
59             =item C
60              
61             =item C
62              
63             =back
64              
65             =cut
66              
67             sub send {
68 2     2 1 4014 my ($self, %arg_hash) = @_;
69 2         14 Eve::Support::arguments(\%arg_hash, my ($to, $subject, $body));
70              
71 2         47 my $email = Email::Simple->create(
72             header => [
73             To => $to,
74             From => $self->_from,
75             Subject => $subject,
76             ],
77             body => $body);
78              
79 2         7295 sendmail($email);
80             }
81              
82             =head1 LICENSE AND COPYRIGHT
83              
84             Copyright 2012 Igor Zinovyev.
85              
86             This program is free software; you can redistribute it and/or modify it
87             under the terms of either: the GNU General Public License as published
88             by the Free Software Foundation; or the Artistic License.
89              
90             See http://dev.perl.org/licenses/ for more information.
91              
92              
93             =head1 AUTHOR
94              
95             =over 4
96              
97             =item L
98              
99             =back
100              
101             =cut
102              
103             1;