line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Egg::View::Mail::Mailer::SMTP; |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# $Id: SMTP.pm 285 2008-02-28 04:20:55Z lushe $ |
6
|
|
|
|
|
|
|
# |
7
|
2
|
|
|
2
|
|
683
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
74
|
|
8
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
131
|
|
9
|
2
|
|
|
2
|
|
11
|
use Carp qw/ croak /; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
126
|
|
10
|
2
|
|
|
2
|
|
4262
|
use Net::SMTP; |
|
2
|
|
|
|
|
107989
|
|
|
2
|
|
|
|
|
539
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub mail_send { |
15
|
0
|
|
|
0
|
1
|
|
my $self= shift; |
16
|
0
|
0
|
|
|
|
|
my $data= $_[0] ? ($_[1] ? {@_}: $_[0]) : croak q{I want mail data.}; |
|
|
0
|
|
|
|
|
|
17
|
0
|
|
0
|
|
|
|
my $host= $data->{smtp_host} || 'localhost'; |
18
|
0
|
|
0
|
|
|
|
my $smtp= Net::SMTP->new( $host, |
19
|
|
|
|
|
|
|
Timeout => ($data->{timeout} || 3), |
20
|
|
|
|
|
|
|
Debug => ($data->{debug} || 0), |
21
|
|
|
|
|
|
|
) || die qq{ '$host' Connection error. }; |
22
|
0
|
|
|
|
|
|
$smtp->mail($data->{from}); |
23
|
0
|
|
|
|
|
|
$smtp->to($data->{to}); |
24
|
0
|
0
|
|
|
|
|
$smtp->cc ($data->{cc}) if $data->{cc}; |
25
|
0
|
0
|
|
|
|
|
$smtp->bcc($data->{bcc}) if $data->{bcc}; |
26
|
0
|
|
|
|
|
|
$smtp->data(); |
27
|
0
|
|
|
|
|
|
$smtp->datasend(${$data->{body}}); |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$smtp->dataend(); |
29
|
0
|
|
|
|
|
|
$smtp->quit(); |
30
|
0
|
|
|
|
|
|
$self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Egg::View::Mail::Mailer::SMTP - Mail is transmitted by using Net::SMTP. |
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_mailer('SMTP'); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
It is Mailer system component to transmit mail by using L<Net::SMTP>. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Use is enabled specifying 'SMTP' for the first argument of 'setup_mailer' method. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 CONFIGURATION |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head3 smtp_host |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
SMTP host name. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Default is 'localhost'. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head3 timeout |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Value of 'Timeout' passed to L<Net::SMTP>. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Default is '3'. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head3 debug |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Value of 'Debug' passed to L<Net::SMTP>. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 METHODS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 mail_send ([MAIL_DATA_HASH]) |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This method is what 'send' method of L<Egg::View::Mail::Base> calls it internally. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The obstacle is generated by operating the component built in when calling |
82
|
|
|
|
|
|
|
directly. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SEE ALSO |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L<Egg::Release>, |
87
|
|
|
|
|
|
|
L<Egg::View::Mail>, |
88
|
|
|
|
|
|
|
L<Egg::View::Mail::Base>, |
89
|
|
|
|
|
|
|
L<Egg::View::Mail::Mailer::CMD>, |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>, All Rights Reserved. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
100
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
101
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|