line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::Send::Sendmail; |
2
|
3
|
|
|
3
|
|
1773
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
96
|
|
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
16
|
use File::Spec (); |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
114
|
|
5
|
|
|
|
|
|
|
BEGIN { |
6
|
3
|
|
|
3
|
|
7
|
local $Return::Value::NO_CLUCK = 1; |
7
|
3
|
|
|
|
|
12
|
require Return::Value; |
8
|
3
|
|
|
|
|
163
|
Return::Value->import; |
9
|
|
|
|
|
|
|
} |
10
|
3
|
|
|
3
|
|
830
|
use Symbol qw(gensym); |
|
3
|
|
|
|
|
880
|
|
|
3
|
|
|
|
|
156
|
|
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
16
|
use vars qw[$SENDMAIL $VERSION]; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1350
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$VERSION = '2.199'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub is_available { |
17
|
8
|
|
|
8
|
0
|
1942
|
my $class = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# This is RIDICULOUS. Why do we say it's available if it isn't? |
20
|
|
|
|
|
|
|
# -- rjbs, 2006-07-06 |
21
|
8
|
100
|
|
|
|
28
|
return success "No Sendmail found" unless $class->_find_sendmail; |
22
|
5
|
|
|
|
|
25
|
return success ''; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _find_sendmail { |
26
|
12
|
|
|
12
|
|
585
|
my $class = shift; |
27
|
12
|
100
|
|
|
|
41
|
return $SENDMAIL if defined $SENDMAIL; |
28
|
|
|
|
|
|
|
|
29
|
6
|
|
|
|
|
6
|
my $sendmail; |
30
|
6
|
100
|
|
|
|
240
|
for my $dir ( |
31
|
|
|
|
|
|
|
File::Spec->path, |
32
|
|
|
|
|
|
|
($ENV{PERL_EMAIL_SEND_SENDMAIL_NO_EXTRA_PATHS} ? () : ( |
33
|
|
|
|
|
|
|
File::Spec->catfile('', qw(usr sbin)), |
34
|
|
|
|
|
|
|
File::Spec->catfile('', qw(usr lib)), |
35
|
|
|
|
|
|
|
)) |
36
|
|
|
|
|
|
|
) { |
37
|
11
|
100
|
|
|
|
304
|
if ( -x "$dir/sendmail" ) { |
38
|
2
|
|
|
|
|
5
|
$sendmail = "$dir/sendmail"; |
39
|
2
|
|
|
|
|
3
|
last; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
6
|
|
|
|
|
36
|
return $sendmail; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub send { |
47
|
3
|
|
|
3
|
0
|
6
|
my ($class, $message, @args) = @_; |
48
|
3
|
|
|
|
|
7
|
my $mailer = $class->_find_sendmail; |
49
|
|
|
|
|
|
|
|
50
|
3
|
50
|
|
|
|
9
|
return failure "Couldn't find 'sendmail' executable in your PATH" |
51
|
|
|
|
|
|
|
." and \$".__PACKAGE__."::SENDMAIL is not set" |
52
|
|
|
|
|
|
|
unless $mailer; |
53
|
|
|
|
|
|
|
|
54
|
3
|
100
|
|
|
|
112
|
return failure "Found $mailer but cannot execute it" |
55
|
|
|
|
|
|
|
unless -x $mailer; |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
51
|
local $SIG{'CHLD'} = 'DEFAULT'; |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
13
|
my $pipe = gensym; |
60
|
|
|
|
|
|
|
|
61
|
2
|
50
|
|
|
|
11753
|
open $pipe, "| $mailer -t -oi @args" |
62
|
|
|
|
|
|
|
or return failure "Error executing $mailer: $!"; |
63
|
2
|
50
|
|
|
|
109
|
print $pipe $message->as_string |
64
|
|
|
|
|
|
|
or return failure "Error printing via pipe to $mailer: $!"; |
65
|
2
|
50
|
|
|
|
4944
|
close $pipe |
66
|
|
|
|
|
|
|
or return failure "error when closing pipe to $mailer: $!"; |
67
|
2
|
|
|
|
|
47
|
return success; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |