line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::SMTP; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
1057603
|
use AnyEvent; |
|
12
|
|
|
|
|
29
|
|
|
12
|
|
|
|
|
282
|
|
4
|
12
|
|
|
12
|
|
11090
|
use common::sense; |
|
12
|
|
|
|
|
134
|
|
|
12
|
|
|
|
|
65
|
|
5
|
12
|
|
|
12
|
|
1184
|
use 5.008008; |
|
12
|
|
|
|
|
47
|
|
|
12
|
|
|
|
|
4609
|
|
6
|
|
|
|
|
|
|
m{# trying to cheat with cpants game ;) |
7
|
|
|
|
|
|
|
use strict; |
8
|
|
|
|
|
|
|
use warnings; |
9
|
|
|
|
|
|
|
}x; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub import { |
12
|
11
|
|
|
11
|
|
87
|
my $me = shift; |
13
|
11
|
|
|
|
|
49
|
my $pkg = caller; |
14
|
11
|
100
|
|
|
|
71
|
@_ or return; |
15
|
10
|
|
|
|
|
162
|
for (@_) { |
16
|
20
|
100
|
|
|
|
112
|
if ( $_ eq 'sendmail') { |
|
|
50
|
|
|
|
|
|
17
|
10
|
|
|
|
|
6538
|
require AnyEvent::SMTP::Client; |
18
|
10
|
|
|
|
|
36
|
*{$pkg.'::'.$_} = \&AnyEvent::SMTP::Client::sendmail; |
|
10
|
|
|
|
|
27884
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
elsif ( $_ eq 'smtp_server') { |
21
|
10
|
|
|
|
|
8320
|
require AnyEvent::SMTP::Server; |
22
|
10
|
|
|
|
|
48
|
*{$pkg.'::'.$_} = \&AnyEvent::SMTP::Server::smtp_server; |
|
10
|
|
|
|
|
120
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
0
|
|
|
|
|
|
require Carp; Carp::croak "$_ is not exported by $me"; |
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
AnyEvent::SMTP - SMTP client and server |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use AnyEvent::SMTP 'sendmail'; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sendmail |
44
|
|
|
|
|
|
|
from => 'mons@cpan.org', |
45
|
|
|
|
|
|
|
to => 'mons@cpan.org', # SMTP host will be detected from addres by MX record |
46
|
|
|
|
|
|
|
data => 'Test message '.time().' '.$$, |
47
|
|
|
|
|
|
|
cb => sub { |
48
|
|
|
|
|
|
|
if (my $ok = shift) { |
49
|
|
|
|
|
|
|
warn "Successfully sent"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
if (my $err = shift) { |
52
|
|
|
|
|
|
|
warn "Failed to send: $err"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use AnyEvent::SMTP 'smtp_server'; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
smtp_server undef, 2525, sub { |
60
|
|
|
|
|
|
|
my $mail = shift; |
61
|
|
|
|
|
|
|
warn "Received mail from $mail->{from} to $mail->{to}\n$mail->{data}\n"; |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 EXPORT |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
By default doesn't export anything. When requested, uses Client or Server exports. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Mons Anderson, C<< >> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Copyright 2009-2011 Mons Anderson, all rights reserved. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
78
|
|
|
|
|
|
|
under the same terms as Perl itself. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; # End of AnyEvent::SMTP |