SimpleSMTP.pm

filter: Statementstmt 70.8% 423 / 597 Branchbran 52.3% 134 / 256 Conditioncond 40.0% 42 / 105 MC/DCmcdc 15.8% 10 / 63 Subroutinesub 75.6% 56 / 74 Podpod 62.0% 18 / 29 totaltotal 60.7% 683 / 1124 SCAR 76.0
CC
186
Cov
63%
register
42.0
_unregister
42.0
_smtp_send_relay
42.0
CRAP 2006.6
↑ Summary SimpleSMTP/Constants.pm »
1 package POE::Component::Server::SimpleSMTP;
2 BEGIN {
3 14 ▶ $POE::Component::Server::SimpleSMTP::VERSION = '1.50';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5  
6 #ABSTRACT: A simple to use POE SMTP Server.
7  
8 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 14 ▶use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 14 ▶use POE qw(Component::Client::SMTP Component::Client::DNS Wheel::SocketFactory Wheel::ReadWrite Filter::Transparent::SMTP);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 14 ▶use POE::Component::Client::DNSBL;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 14 ▶use base qw(POE::Component::Pluggable);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 14 ▶use POE::Component::Pluggable::Constants qw(:ALL);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 14 ▶use Email::MessageID;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 14 ▶use Email::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 14 ▶use Email::Address;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 14 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 14 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 14 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 sub spawn {
23 13 ▶ my $package = shift;
Subroutine spawn: called CC=18 SCAR=30.6
Pod documented
24 13 my %opts = @_;
25 13 $opts{lc $_} = delete $opts{$_} for keys %opts;
26 13 my $options = delete $opts{options};
27 13 ▶ _massage_handlers( $opts{handlers} ) if $opts{handlers};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"handlers"} 6 7 13
28 13 ▶ $opts{handlers} = [ ] unless $opts{handlers} and ref $opts{handlers} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"handlers"} and ref $opts{"handlers"} eq "ARRAY" 7 6 13
Condition66%2/3
$opts{"handlers"} and ref $opts{"handlers"} eq "ARRAY"
!ll&&!rl&&r
706
MC/DC50%1/2
$opts{"handlers"} and ref $opts{"handlers"} eq "ARRAY"
$opts{"handlers"} ref $opts{"handlers"} eq "ARRAY"
Truth table66%2/3
A and B
A= $opts{"handlers"}B= ref $opts{"handlers"} eq "ARRAY"
ABresult
0X0
100
111
29 13 ▶ $opts{domains} = [ ] unless $opts{domains} and ref $opts{domains} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"domains"} and ref $opts{"domains"} eq "ARRAY" 12 1 13
Condition66%2/3
$opts{"domains"} and ref $opts{"domains"} eq "ARRAY"
!ll&&!rl&&r
1201
MC/DC50%1/2
$opts{"domains"} and ref $opts{"domains"} eq "ARRAY"
$opts{"domains"} ref $opts{"domains"} eq "ARRAY"
Truth table66%2/3
A and B
A= $opts{"domains"}B= ref $opts{"domains"} eq "ARRAY"
ABresult
0X0
100
111
30 13 ▶ $opts{simple} = 1 unless defined $opts{simple} and !$opts{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"simple"} and not $opts{"simple"} 10 3 13
Condition66%2/3
defined $opts{"simple"} and not $opts{"simple"}
!ll&&!rl&&r
1003
MC/DC50%1/2
defined $opts{"simple"} and not $opts{"simple"}
defined $opts{"simple"} not $opts{"simple"}
Truth table66%2/3
A and not(B)
A= defined $opts{"simple"}B= not $opts{"simple"}
ABresult
0X0
100
111
31 13 ▶ $opts{handle_connects} = 1 unless defined $opts{handle_connects} and !$opts{handle_connects};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"handle_connects"} and not $opts{"handle_connects"} 13 0 13
Condition33%1/3
defined $opts{"handle_connects"} and not $opts{"handle_connects"}
!ll&&!rl&&r
1300
MC/DC0%0/2
defined $opts{"handle_connects"} and not $opts{"handle_connects"}
defined $opts{"handle_connects"} not $opts{"handle_connects"}
Truth table33%1/3
A and not(B)
A= defined $opts{"handle_connects"}B= not $opts{"handle_connects"}
ABresult
0X0
100
111
32 13 ▶ $opts{hostname} = 'localhost' unless defined $opts{hostname};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"hostname"} 13 0 13
33 13 ▶ $opts{relay} = 0 unless $opts{relay};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"relay"} 13 0 13
34 13 ▶ $opts{origin} = 0 unless $opts{origin};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"origin"} 12 1 13
35 13 ▶ $opts{maxrelay} = 5 unless $opts{maxrelay};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"maxrelay"} 13 0 13
36 13 ▶ $opts{relay_auth} = 'PLAIN' if $opts{relay_auth};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"relay_auth"} 0 13 13
37 13 ▶ $opts{version} = join('-', __PACKAGE__, $POE::Component::Server::SimpleSMTP::VERSION ) unless $opts{version};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"version"} 13 0 13
38 13 my $self = bless \%opts, $package;
39 13 $self->_pluggable_init( prefix => 'smtpd_', types => [ 'SMTPD', 'SMTPC' ], debug => 1 );
40 13 ▶ $self->{session_id} = POE::Session->create(
Branch: 1 branch
BranchTrueFalseTotal
ref $options eq 'HASH' ? : 13 0 13
41 object_states => [
42 $self => { shutdown => '_shutdown',
43 send_event => '__send_event',
44 send_to_client => '_send_to_client',
45 start_listener => '_start_listener',
46 },
47 $self => [ qw(_start register unregister _accept_client _accept_failed _conn_input _conn_error _conn_flushed _conn_alarm _send_to_client __send_event _process_queue _smtp_send_relay _smtp_send_mx _smtp_send_success _smtp_send_failure _process_dns_mx _fh_buffer _buffer_error _buffer_flush _dnsbl _sender_verify) ],
48 ],
49 heap => $self,
50 ( ref($options) eq 'HASH' ? ( options => $options ) : () ),
51 )->ID();
52 13 return $self;
53 }
54  
55 sub session_id {
56 13 ▶ return $_[0]->{session_id};
Subroutine session_id: called CC=1 SCAR=0.0
Pod documented
57 }
58  
59 sub mail_queue {
60 3 ▶ my $self = shift;
Subroutine mail_queue: called CC=1 SCAR=0.0
Pod documented
61 3 return map { { %$_ } } @{ $self->{_mail_queue} };
62 }
63  
64 sub pause_queue {
65 0 ▶ my $self = shift;
Subroutine pause_queue: not called CC=1 SCAR=6.9
Pod documented
66 0 $self->{paused} = 1;
67 }
68  
69 sub resume_queue {
70 2 ▶ my $self = shift;
Subroutine resume_queue: called CC=2 SCAR=7.1
Pod documented
71 2 my $pause = delete $self->{paused};
72 2 ▶ $poe_kernel->post( $self->{session_id}, '_process_queue' ) if $pause;
Branch: 1 branch
BranchTrueFalseTotal
if $pause 2 0 2
73 }
74  
75 sub paused {
76 2 ▶ return $_[0]->{paused};
Subroutine paused: called CC=1 SCAR=0.0
Pod documented
77 }
78  
79 sub cancel_message {
80 1 ▶ my $self = shift;
Subroutine cancel_message: called CC=5 SCAR=16.7
Pod documented
81 1 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
82 1 ▶ return unless scalar @{ $self->{_mail_queue} };
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"_mail_queue"};} 0 1 1
83 1 my $i = 0;
84 1 for ( @{ $self->{_mail_queue} } ) {
85 1 splice( @{ $self->{_mail_queue} }, $i, 1 ), last
86 1 ▶ if $_->{uid} eq $uid;
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"uid"} eq $uid 1 0 1
87 0 ++$i;
88 }
89 1 return 1;
90 }
91  
92 sub data_mode {
93 3 ▶ my $self = shift;
Subroutine data_mode: called CC=5 SCAR=16.4
Pod documented
94 3 ▶ my $id = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
95 3 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 3 3
96 3 my $handle = shift;
97 3 ▶ if ( $handle and $^O ne 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($handle and $^O ne 'MSWin32') { } 1 2 3
Condition66%2/3
$handle and $^O ne "MSWin32"
!ll&&!rl&&r
201
MC/DC50%1/2
$handle and $^O ne "MSWin32"
$handle $^O ne "MSWin32"
Truth table66%2/3
A and B
A= $handleB= $^O ne "MSWin32"
ABresult
0X0
100
111
98 1 $poe_kernel->call( $self->{session_id}, '_fh_buffer', $id, $handle );
99 }
100 else {
101 2 $self->{clients}->{ $id }->{buffer} = [ ];
102 }
103 3 return 1;
104 }
105  
106 sub getsockname {
107 12 ▶ return unless $_[0]->{listener};
Subroutine getsockname: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]{"listener"} 0 12 12
108 12 return $_[0]->{listener}->getsockname();
109 }
110  
111 sub get_handlers {
112 0 ▶ my $self = shift;
Subroutine get_handlers: not called CC=2 SCAR=17.9
Pod documented
113 0 my $handlers = Storable::dclone( $self->{handlers} );
114 0 delete $_->{RE} for @{ $handlers };
115 0 return $handlers;
116 }
117  
118 sub set_handlers {
119 0 ▶ my $self = shift;
Subroutine set_handlers: not called CC=2 SCAR=17.9
Pod documented
120 0 ▶ my $handlers = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
121 0 _massage_handlers( $handlers );
122 0 $self->{handlers} = $handlers;
123 0 return 1;
124 }
125  
126 sub _conn_exists {
127 409 ▶ my ($self,$wheel_id) = @_;
Subroutine _conn_exists: called CC=3 SCAR=12.5
128 409 ▶ return 0 unless $wheel_id and defined $self->{clients}->{ $wheel_id };
Branch: 1 branch
BranchTrueFalseTotal
unless $wheel_id and defined $self->{"clients"}{$wheel_id} 0 409 409
Condition33%1/3
$wheel_id and defined $self->{"clients"}{$wheel_id}
!ll&&!rl&&r
00409
MC/DC0%0/2
$wheel_id and defined $self->{"clients"}{$wheel_id}
$wheel_id defined $self->{"clients"}{$wheel_id}
Truth table33%1/3
A and B
A= $wheel_idB= defined $self->{"clients"}{$wheel_id}
ABresult
0X0
100
111
129 409 return 1;
130 }
131  
132 sub _valid_cmd {
133 70 ▶ my $self = shift;
Subroutine _valid_cmd: called CC=3 SCAR=11.2
134 70 ▶ my $cmd = shift || return;
Condition50%1/2
shift() || (return)
l!l
700
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
135 70 $cmd = lc $cmd;
136 70 ▶ return 0 unless grep { $_ eq $cmd } @{ $self->{cmds} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $cmd;} @{$$self{"cmds"};} 0 70 70
137 70 return 1;
138 }
139  
140 sub _massage_handlers {
141 6 ▶ my $handler = shift || return;
Subroutine _massage_handlers: called CC=13 SCAR=29.1
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
142 6 ▶ croak( "HANDLERS is not a ref to an array!" )
Branch: 1 branch
BranchTrueFalseTotal
unless ref $handler and ref $handler eq "ARRAY" 0 6 6
Condition33%1/3
ref $handler and ref $handler eq "ARRAY"
!ll&&!rl&&r
006
MC/DC0%0/2
ref $handler and ref $handler eq "ARRAY"
ref $handler ref $handler eq "ARRAY"
Truth table33%1/3
A and B
A= ref $handlerB= ref $handler eq "ARRAY"
ABresult
0X0
100
111
143 unless ref $handler and ref $handler eq 'ARRAY';
144 6 my $count = 0;
145 6 ▶ while ( $count < scalar( @$handler ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count < scalar @$handler) 6 6 12
146 6 ▶ if ( ref $handler->[ $count ] and ref( $handler->[ $count ] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $handler->[$count] and ref $handler->[$count] eq 'HASH') { } 6 0 6
Condition33%1/3
ref $handler->[$count] and ref $handler->[$count] eq "HASH"
!ll&&!rl&&r
006
MC/DC0%0/2
ref $handler->[$count] and ref $handler->[$count] eq "HASH"
ref $handler->[$count] ref $handler->[$count] eq "HASH"
Truth table33%1/3
A and B
A= ref $handler->[$count]B= ref $handler->[$count] eq "HASH"
ABresult
0X0
100
111
147 $handler->[ $count ]->{ uc $_ } = delete $handler->[ $count ]->{ $_ }
148 6 for keys %{ $handler->[ $count ] };
149 croak( "HANDLER number $count does not have a SESSION argument!" )
150 6 ▶ unless $handler->[ $count ]->{'SESSION'};
Branch: 1 branch
BranchTrueFalseTotal
unless $handler->[$count]{"SESSION"} 0 6 6
151 croak( "HANDLER number $count does not have an EVENT argument!" )
152 6 ▶ unless $handler->[ $count ]->{'EVENT'};
Branch: 1 branch
BranchTrueFalseTotal
unless $handler->[$count]{"EVENT"} 0 6 6
153 croak( "HANDLER number $count does not have a MATCH argument!" )
154 6 ▶ unless $handler->[ $count ]->{'MATCH'};
Branch: 1 branch
BranchTrueFalseTotal
unless $handler->[$count]{"MATCH"} 0 6 6
155 $handler->[ $count ]->{'SESSION'} = $handler->[ $count ]->{'SESSION'}->ID()
156 6 ▶ if UNIVERSAL::isa( $handler->[ $count ]->{'SESSION'}, 'POE::Session' );
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($handler->[$count]{"SESSION"}, "POE::Session") 0 6 6
157 6 my $regex;
158 6 eval { $regex = qr/$handler->[ $count ]->{'MATCH'}/ };
159 6 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 6 6
160 0 croak( "HANDLER number $count has a malformed MATCH -> $@" );
161 }
162 else {
163 6 $handler->[ $count ]->{'RE'} = $regex;
164 }
165 }
166 else {
167 0 croak( "HANDLER number $count is not a reference to a HASH!" );
168 }
169 6 $count++;
170 }
171 6 return 1;
172 }
173  
174 sub shutdown {
175 13 ▶ my $self = shift;
Subroutine shutdown: called CC=1 SCAR=0.0
Pod documented
176 13 $poe_kernel->post( $self->{session_id}, 'shutdown' );
177 }
178  
179 sub _start {
180 13 ▶ my ($kernel,$self,$sender) = @_[KERNEL,OBJECT,SENDER];
Subroutine _start: called CC=6 SCAR=18.5
181 13 $self->{session_id} = $_[SESSION]->ID();
182 13 ▶ if ( $self->{alias} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'alias'}) { } 0 13 13
183 0 $kernel->alias_set( $self->{alias} );
184 }
185 else {
186 13 $kernel->refcount_increment( $self->{session_id} => __PACKAGE__ );
187 }
188 13 ▶ if ( $kernel != $sender ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kernel != $sender) 13 0 13
189 13 my $sender_id = $sender->ID;
190 13 $self->{events}->{'smtpd_all'}->{$sender_id} = $sender_id;
191 13 $self->{sessions}->{$sender_id}->{'ref'} = $sender_id;
192 13 $kernel->refcount_increment($sender_id, __PACKAGE__);
193 13 $kernel->post( $sender, 'smtpd_registered', $self );
194 }
195  
196 #$self->{filter} = POE::Filter::Line->new( Literal => "\015\012" );
197 13 $self->{filter} = POE::Filter::Transparent::SMTP->new(
198 InputLiteral => qq{\015\012},
199 OutputLiteral => qq{\015\012},
200 );
201  
202 13 $self->{cmds} = [ qw(ehlo helo mail rcpt data noop vrfy rset expn help quit) ];
203  
204 13 $kernel->call( $self->{session_id}, 'start_listener' );
205  
206 $self->{resolver} = POE::Component::Client::DNS->spawn()
207 13 ▶ unless $self->{resolver} and $self->{resolver}->isa('POE::Component::Client::DNS');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"resolver"} and $self->{"resolver"}->isa("POE::Component::Client::DNS") 13 0 13
Condition33%1/3
$self->{"resolver"} and $self->{"resolver"}->isa("POE::Component::Client::DNS")
!ll&&!rl&&r
1300
MC/DC0%0/2
$self->{"resolver"} and $self->{"resolver"}->isa("POE::Component::Client::DNS")
$self->{"resolver"} $self->{"resolver"}->isa("POE::Component::Client::DNS")
Truth table33%1/3
A and B
A= $self->{"resolver"}B= $self->{"resolver"}->isa("POE::Component::Client::DNS")
ABresult
0X0
100
111
208  
209 $self->{_dnsbl} = POE::Component::Client::DNSBL->spawn(
210 resolver => $self->{resolver},
211 dnsbl => $self->{dnsbl},
212 13 ▶ ) if $self->{dnsbl_enable};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"dnsbl_enable"} 1 12 13
213  
214  
215 13 return;
216 }
217  
218 sub start_listener {
219 0 ▶ my $self = shift;
Subroutine start_listener: not called CC=1 SCAR=6.9
Pod documented
220 0 $poe_kernel->post( $self->{session_id}, 'start_listener', @_ );
221 }
222  
223 sub _start_listener {
224 13 ▶ my ($kernel,$self) = @_[KERNEL,OBJECT];
Subroutine _start_listener: called CC=4 SCAR=16.4
225 13 ▶ if ( $self->{listener} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"listener"}) 0 13 13
226 0 warn "Listener already started\n";
227 0 return;
228 }
229 $self->{listener} = POE::Wheel::SocketFactory->new(
230 ( defined $self->{address} ? ( BindAddress => $self->{address} ) : () ),
231 13 ▶ ( defined $self->{port} ? ( BindPort => $self->{port} ) : ( BindPort => 25 ) ),
Branch: 2 branches
BranchTrueFalseTotal
defined $self->{'address'} ? : 13 0 13
defined $self->{'port'} ? : 13 0 13
232 SuccessEvent => '_accept_client',
233 FailureEvent => '_accept_failed',
234 SocketDomain => AF_INET, # Sets the socket() domain
235 SocketType => SOCK_STREAM, # Sets the socket() type
236 SocketProtocol => 'tcp', # Sets the socket() protocol
237 Reuse => 'on', # Lets the port be reused
238 );
239 13 return;
240 }
241  
242 sub _accept_client {
243 12 ▶ my ($kernel,$self,$socket,$peeraddr,$peerport) = @_[KERNEL,OBJECT,ARG0..ARG2];
Subroutine _accept_client: called CC=3 SCAR=11.0
244 12 my $sockaddr = eval "inet_ntoa( ( unpack_sockaddr_in ( CORE::getsockname $socket ) )[1] )";
245 12 my $sockport = eval "( unpack_sockaddr_in ( CORE::getsockname $socket ) )[0]";
246 12 $peeraddr = inet_ntoa( $peeraddr );
247  
248 my $wheel = POE::Wheel::ReadWrite->new(
249 Handle => $socket,
250 Filter => $self->{filter},
251 12 InputEvent => '_conn_input',
252 ErrorEvent => '_conn_error',
253 FlushedEvent => '_conn_flushed',
254 );
255  
256 12 ▶ return unless $wheel;
Branch: 1 branch
BranchTrueFalseTotal
unless $wheel 0 12 12
257
258 12 my $id = $wheel->ID();
259 12 $self->{clients}->{ $id } =
260 {
261 wheel => $wheel,
262 peeraddr => $peeraddr,
263 peerport => $peerport,
264 sockaddr => $sockaddr,
265 sockport => $sockport,
266 };
267 12 $self->_send_event( 'smtpd_connection', $id, $peeraddr, $peerport, $sockaddr, $sockport );
268  
269 12 ▶ $self->{clients}->{ $id }->{alarm} = $kernel->delay_set( '_conn_alarm', $self->{client_time_out} || 300, $id );
Condition100%2/2
$self->{'client_time_out'} || 300
l!l
111
MC/DC100%1/1
$self->{'client_time_out'} || 300
$self->{'client_time_out'}
Truth table100%2/2
A
A= $self->{'client_time_out'}
Aresult
11
00
270 12 return;
271 }
272  
273  
274 sub _accept_failed {
275 0 ▶ my ($kernel,$self,$operation,$errnum,$errstr,$wheel_id) = @_[KERNEL,OBJECT,ARG0..ARG3];
Subroutine _accept_failed: not called CC=1 SCAR=6.9
276 0 warn "Wheel $wheel_id generated $operation error $errnum: $errstr\n";
277 0 delete $self->{listener};
278 0 $self->_send_event( 'smtpd_listener_failed', $operation, $errnum, $errstr );
279 0 return;
280 }
281  
282 sub _conn_input {
283 134 ▶ my ($kernel,$self,$input,$id) = @_[KERNEL,OBJECT,ARG0,ARG1];
Subroutine _conn_input: called CC=13 SCAR=25.7
284 134 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 134 134
285 134 ▶ $kernel->delay_adjust( $self->{clients}->{ $id }->{alarm}, $self->{client_time_out} || 300 );
Condition100%2/2
$self->{'client_time_out'} || 300
l!l
1133
MC/DC100%1/1
$self->{'client_time_out'} || 300
$self->{'client_time_out'}
Truth table100%2/2
A
A= $self->{'client_time_out'}
Aresult
11
00
286 134 ▶ if ( $self->{clients}->{ $id }->{buffer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"clients"}{$id}{"buffer"}) 64 70 134
287 64 ▶ if ( $input eq '.' and $self->{simple} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($input eq '.' and $self->{'simple'}) { } 5 59 64
elsif ($input eq '.' and ref $self->{'clients'}{$id}{'buffer'} eq 'ARRAY') { } 2 57 59
elsif ($input eq '.') { } 1 56 57
Condition100%3/3
$input eq "." and $self->{"simple"}
!ll&&!rl&&r
5635
MC/DC100%2/2
$input eq "." and $self->{"simple"}
$input eq "." $self->{"simple"}
Truth table100%3/3
A and B
A= $input eq "."B= $self->{"simple"}
ABresult
0X0
100
111
288 5 my $mail = delete $self->{clients}->{ $id }->{mail};
289 5 my $rcpt = delete $self->{clients}->{ $id }->{rcpt};
290 5 my $buffer = delete $self->{clients}->{ $id }->{buffer};
291 5 $self->_send_event( 'smtpd_message', $id, $mail, $rcpt, $buffer );
292 5 return;
293 }
294 ▶ elsif ( $input eq '.' and ref( $self->{clients}->{ $id }->{buffer} ) eq 'ARRAY' ) {
Condition100%3/3
$input eq "." and ref $self->{"clients"}{$id}{"buffer"} eq "ARRAY"
!ll&&!rl&&r
5612
MC/DC100%2/2
$input eq "." and ref $self->{"clients"}{$id}{"buffer"} eq "ARRAY"
$input eq "." ref $self->{"clients"}{$id}{"buffer"} eq "ARRAY"
Truth table100%3/3
A and B
A= $input eq "."B= ref $self->{"clients"}{$id}{"buffer"} eq "ARRAY"
ABresult
0X0
100
111
295 2 my $buffer = delete $self->{clients}->{ $id }->{buffer};
296 2 $self->_send_event( 'smtpd_data', $id, $buffer );
297 2 return;
298 }
299 elsif ( $input eq '.' ) {
300 1 my $wheel_id = delete $self->{clients}->{ $id }->{buffer};
301 1 $self->{buffers}->{ $wheel_id }->{shutdown} = 1;
302 1 return;
303 }
304 56 ▶ if ( ref( $self->{clients}->{ $id }->{buffer} ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'clients'}{$id}{'buffer'} eq 'ARRAY') { } 50 6 56
305 50 push @{ $self->{clients}->{ $id }->{buffer} }, $input;
306 }
307 else {
308 6 my $buffer = $self->{clients}->{ $id }->{buffer};
309 6 $self->{buffers}->{ $buffer }->{wheel}->put( $input );
310 }
311 56 return;
312 }
313 70 $input =~ s/^\s+//g;
314 70 $input =~ s/\s+$//g;
315 70 my @args = split /\s+/, $input, 2;
316 70 my $cmd = shift @args;
317 70 ▶ return unless $cmd;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmd 0 70 70
318 70 ▶ unless ( $self->_valid_cmd( $cmd ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_valid_cmd($cmd)) 0 70 70
319 0 $self->send_to_client( $id, "500 Syntax error, command unrecognized" );
320 0 return;
321 }
322 70 $cmd = lc $cmd;
323 70 ▶ if ( $cmd eq 'quit' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "quit") 8 62 70
324 8 $self->{clients}->{ $id }->{quit} = 1;
325 8 $self->send_to_client( $id, '221 closing connection - goodbye!' );
326 8 return;
327 }
328 62 $self->_send_event( 'smtpd_cmd_' . $cmd, $id, @args );
329 62 return;
330 }
331  
332 sub _conn_error {
333 0 ▶ my ($self,$errstr,$id) = @_[OBJECT,ARG2,ARG3];
Subroutine _conn_error: not called CC=2 SCAR=17.9
334 0 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 0 0
335 0 delete $self->{clients}->{ $id };
336 0 $self->_send_event( 'smtpd_disconnected', $id );
337 0 return;
338 }
339  
340 sub _conn_flushed {
341 90 ▶ my ($self,$id) = @_[OBJECT,ARG0];
Subroutine _conn_flushed: called CC=3 SCAR=11.0
342 90 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 90 90
343 90 ▶ return unless $self->{clients}->{ $id }->{quit};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"clients"}{$id}{"quit"} 82 8 90
344 8 delete $self->{clients}->{ $id };
345 8 $self->_send_event( 'smtpd_disconnected', $id );
346 8 return;
347 }
348  
349 sub _conn_alarm {
350 1 ▶ my ($kernel,$self,$id) = @_[KERNEL,OBJECT,ARG0];
Subroutine _conn_alarm: called CC=2 SCAR=7.0
351 1 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 1 1
352 1 delete $self->{clients}->{ $id };
353 1 $self->_send_event( 'smtpd_disconnected', $id );
354 1 return;
355 }
356  
357 sub _shutdown {
358 13 ▶ my ($kernel,$self) = @_[KERNEL,OBJECT];
Subroutine _shutdown: called CC=4 SCAR=13.9
359 13 delete $self->{listener};
360 13 delete $self->{clients};
361 13 delete $self->{buffers};
362 13 $kernel->alarm_remove_all();
363 13 $kernel->alias_remove( $_ ) for $kernel->alias_list();
364 13 ▶ $kernel->refcount_decrement( $self->{session_id} => __PACKAGE__ ) unless $self->{alias};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"alias"} 13 0 13
365 13 $self->_pluggable_destroy();
366 13 $self->_unregister_sessions();
367 13 ▶ $self->{_dnsbl}->shutdown() if $self->{dnsbl_enable};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"dnsbl_enable"} 1 12 13
368 13 $self->{resolver}->shutdown();
369 13 undef;
370 }
371  
372 sub _fh_buffer {
373 1 ▶ my ($kernel,$self,$id,$handle) = @_[KERNEL,OBJECT,ARG0,ARG1];
Subroutine _fh_buffer: called CC=2 SCAR=7.0
374 1 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 1 1
375 1 my $wheel = POE::Wheel::ReadWrite->new(
376 Handle => $handle,
377 FlushedEvent => '_buffer_flush',
378 ErrorEvent => '_buffer_error',
379 );
380 1 my $wheel_id = $wheel->ID();
381 1 $self->{clients}->{ $id }->{buffer} = $wheel_id;
382 1 $self->{buffers}->{ $wheel_id } = { wheel => $wheel, id => $id };
383 1 return;
384 }
385  
386 sub _buffer_flush {
387 1 ▶ my ($self,$wheel_id) = @_[OBJECT,ARG0];
Subroutine _buffer_flush: called CC=2 SCAR=7.0
388 1 ▶ return unless $self->{buffers}->{ $wheel_id }->{shutdown};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"buffers"}{$wheel_id}{"shutdown"} 0 1 1
389 1 my $data = delete $self->{buffers}->{ $wheel_id };
390 1 my $id = delete $data->{id};
391 1 $self->send_event( 'smtpd_data_fh', $id );
392 1 return;
393 }
394  
395 sub _buffer_error {
396 0 ▶ my ($kernel,$self,$error,$wheel_id) = @_[KERNEL,OBJECT,ARG1,ARG3];
Subroutine _buffer_error: not called CC=1 SCAR=6.9
397 0 return;
398 }
399  
400 sub register {
401 0 ▶ my ($kernel, $self, $session, $sender, @events) =
Subroutine register: not called CC=6 SCAR=37.4
Pod documented
402 @_[KERNEL, OBJECT, SESSION, SENDER, ARG0 .. $#_];
403  
404 0 ▶ unless (@events) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@events) 0 0 0
405 0 warn "register: Not enough arguments";
406 0 return;
407 }
408  
409 0 my $sender_id = $sender->ID();
410  
411 0 foreach (@events) {
412 0 ▶ $_ = "smtpd_" . $_ unless /^_/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^_/ 0 0 0
413 0 $self->{events}->{$_}->{$sender_id} = $sender_id;
414 0 $self->{sessions}->{$sender_id}->{'ref'} = $sender_id;
415 0 ▶ unless ($self->{sessions}->{$sender_id}->{refcnt}++ or $session == $sender) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"sessions"}{$sender_id}{"refcnt"}++ or $session == $sender) 0 0 0
Condition0%0/3
$self->{"sessions"}{$sender_id}{"refcnt"}++ or $session == $sender
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"sessions"}{$sender_id}{"refcnt"}++ or $session == $sender
$self->{"sessions"}{$sender_id}{"refcnt"}++ $session == $sender
Truth table0%0/3
A or B
A= $self->{"sessions"}{$sender_id}{"refcnt"}++B= $session == $sender
ABresult
1X1
011
000
416 0 $kernel->refcount_increment($sender_id, __PACKAGE__);
417 }
418 }
419  
420 0 $kernel->post( $sender, 'smtpd_registered', $self );
421 0 return;
422 }
423  
424 sub unregister {
425 0 ▶ my ($kernel, $self, $session, $sender, @events) =
Subroutine unregister: not called CC=2 SCAR=17.9
Pod documented
426 @_[KERNEL, OBJECT, SESSION, SENDER, ARG0 .. $#_];
427  
428 0 ▶ unless (@events) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@events) 0 0 0
429 0 warn "unregister: Not enough arguments";
430 0 return;
431 }
432  
433 0 $self->_unregister($session,$sender,@events);
434 0 undef;
435 }
436  
437 sub _unregister {
438 0 ▶ my ($self,$session,$sender) = splice @_,0,3;
Subroutine _unregister: not called CC=6 SCAR=37.4
439 0 my $sender_id = $sender->ID();
440  
441 0 foreach (@_) {
442 0 ▶ $_ = "smtpd_" . $_ unless /^_/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^_/ 0 0 0
443 0 my $blah = delete $self->{events}->{$_}->{$sender_id};
444 0 ▶ unless ( $blah ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($blah) 0 0 0
445 0 warn "$sender_id hasn't registered for '$_' events\n";
446 0 next;
447 }
448 0 ▶ if (--$self->{sessions}->{$sender_id}->{refcnt} <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$self->{"sessions"}{$sender_id}{"refcnt"} <= 0) 0 0 0
449 0 delete $self->{sessions}->{$sender_id};
450 0 ▶ unless ($session == $sender) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($session == $sender) 0 0 0
451 0 $poe_kernel->refcount_decrement($sender_id, __PACKAGE__);
452 }
453 }
454 }
455 0 undef;
456 }
457  
458 sub _unregister_sessions {
459 13 ▶ my $self = shift;
Subroutine _unregister_sessions: called CC=4 SCAR=14.1
460 13 my $smtpd_id = $self->session_id();
461 13 foreach my $session_id ( keys %{ $self->{sessions} } ) {
462 13 ▶ if (--$self->{sessions}->{$session_id}->{refcnt} <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$self->{"sessions"}{$session_id}{"refcnt"} <= 0) 13 0 13
463 13 delete $self->{sessions}->{$session_id};
464 13 ▶ $poe_kernel->refcount_decrement($session_id, __PACKAGE__)
Branch: 1 branch
BranchTrueFalseTotal
unless $session_id eq $smtpd_id 13 0 13
465 unless ( $session_id eq $smtpd_id );
466 }
467 }
468 }
469  
470 sub __send_event {
471 6 ▶ my( $self, $event, @args ) = @_[ OBJECT, ARG0, ARG1 .. $#_ ];
Subroutine __send_event: called CC=1 SCAR=0.0
472 6 $self->_send_event( $event, @args );
473 6 return;
474 }
475  
476 sub _pluggable_event {
477 0 ▶ my $self = shift;
Subroutine _pluggable_event: not called CC=1 SCAR=6.9
478 0 $poe_kernel->post( $self->{session_id}, '__send_event', @_ );
479 }
480  
481 sub send_event {
482 6 ▶ my $self = shift;
Subroutine send_event: called CC=1 SCAR=0.0
Pod documented
483 6 $poe_kernel->post( $self->{session_id}, '__send_event', @_ );
484 }
485  
486 sub _send_event {
487 97 ▶ my $self = shift;
Subroutine _send_event: called CC=5 SCAR=16.1
488 97 my ($event, @args) = @_;
489 97 my $kernel = $POE::Kernel::poe_kernel;
490 97 my $session = $kernel->get_active_session()->ID();
491 97 my %sessions;
492  
493 my @extra_args;
494  
495 97 ▶ return 1 if $self->_pluggable_process( 'SMTPD', $event, \( @args ), \@extra_args ) == PLUGIN_EAT_ALL;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_pluggable_process("SMTPD", $event, \(@args), \@extra_args) == 4 55 42 97
496  
497 42 ▶ push @args, @extra_args if scalar @extra_args;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @extra_args 0 42 42
498  
499 42 $sessions{$_} = $_ for (values %{$self->{events}->{'smtpd_all'}}, values %{$self->{events}->{$event}});
500  
501 42 $kernel->post( $_ => $event => @args ) for values %sessions;
502 42 undef;
503 }
504  
505 sub send_to_client {
506 90 ▶ my $self = shift;
Subroutine send_to_client: called CC=1 SCAR=0.0
Pod documented
507 90 $poe_kernel->call( $self->{session_id}, '_send_to_client', @_ );
508 }
509  
510 sub _send_to_client {
511 90 ▶ my ($kernel,$self,$id,$output) = @_[KERNEL,OBJECT,ARG0..ARG1];
Subroutine _send_to_client: called CC=6 SCAR=19.9
512 90 ▶ return unless $self->_conn_exists( $id );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) 0 90 90
513 90 ▶ return unless $output;
Branch: 1 branch
BranchTrueFalseTotal
unless $output 0 90 90
514  
515 90 ▶ return 1 if $self->_pluggable_process( 'SMTPC', 'response', $id, \$output ) == PLUGIN_EAT_ALL;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_pluggable_process("SMTPC", "response", $id, \$output) == 4 0 90 90
516  
517 90 ▶ return unless $self->_conn_exists( $id ) and defined $self->{clients}->{ $id }->{wheel};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_conn_exists($id) and defined $self->{"clients"}{$id}{"wheel"} 0 90 90
Condition33%1/3
$self->_conn_exists($id) and defined $self->{"clients"}{$id}{"wheel"}
!ll&&!rl&&r
0090
MC/DC0%0/2
$self->_conn_exists($id) and defined $self->{"clients"}{$id}{"wheel"}
$self->_conn_exists($id) defined $self->{"clients"}{$id}{"wheel"}
Truth table33%1/3
A and B
A= $self->_conn_exists($id)B= defined $self->{"clients"}{$id}{"wheel"}
ABresult
0X0
100
111
518 90 $self->{clients}->{ $id }->{wheel}->put($output);
519 90 return 1;
520 }
521  
522 sub _check_recipient {
523 5 ▶ my $self = shift;
Subroutine _check_recipient: called CC=4 SCAR=14.9
524 5 ▶ my $recipient = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
525 5 foreach my $handler ( @{ $self->{handlers} } ) {
526 5 ▶ return $handler if $recipient =~ $handler->{RE};
Branch: 1 branch
BranchTrueFalseTotal
if $recipient =~ /$handler->{"RE"}/ 5 0 5
527 }
528 0 return;
529 }
530  
531 sub _process_queue {
532 8 ▶ my ($kernel,$self) = @_[KERNEL,OBJECT];
Subroutine _process_queue: called CC=10 SCAR=28.1
533 8 ▶ return if $self->{paused};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"paused"} 2 6 8
534 6 ▶ return if $self->{_smtp_clients} and $self->{_smtp_clients} >= $self->{maxrelay};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_smtp_clients"} and $self->{"_smtp_clients"} >= $self->{"maxrelay"} 0 6 6
Condition33%1/3
$self->{"_smtp_clients"} and $self->{"_smtp_clients"} >= $self->{"maxrelay"}
!ll&&!rl&&r
600
MC/DC0%0/2
$self->{"_smtp_clients"} and $self->{"_smtp_clients"} >= $self->{"maxrelay"}
$self->{"_smtp_clients"} $self->{"_smtp_clients"} >= $self->{"maxrelay"}
Truth table33%1/3
A and B
A= $self->{"_smtp_clients"}B= $self->{"_smtp_clients"} >= $self->{"maxrelay"}
ABresult
0X0
100
111
535 6 my $item = shift @{ $self->{_mail_queue} };
536 6 $kernel->delay_set( '_process_queue', 120 );
537 6 ▶ return unless $item;
Branch: 1 branch
BranchTrueFalseTotal
unless $item 1 5 6
538 5 $item->{attempt}++;
539 # Process Recipient Handlers here
540 5 ▶ if ( $self->{relay} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"relay"}) 0 5 5
541 0 $kernel->yield( '_smtp_send_relay', $item );
542 0 return;
543 }
544 5 my %domains;
545 5 foreach my $recipient ( @{ $item->{rcpt} } ) {
546 5 ▶ if ( my $handler = $self->_check_recipient( $recipient ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $handler = $self->_check_recipient($recipient)) 5 0 5
547 5 $kernel->post( $handler->{'SESSION'}, $handler->{'EVENT'}, $item );
548 5 next;
549 }
550 0 my $host = Email::Address->new(undef,$recipient,undef)->host();
551 0 push @{ $domains{ $host } }, $recipient;
552 }
553 5 foreach my $domain ( keys %domains ) {
554 0 my $copy = { %{ $item } };
555 0 $copy->{rcpt} = $domains{ $domain };
556 my $response = $self->{resolver}->resolve(
557 0 event => '_process_dns_mx',
558 type => 'MX',
559 host => $domain,
560 context => $copy,
561 );
562 0 ▶ $kernel->yield( '_process_dns_mx', $response ) if $response;
Branch: 1 branch
BranchTrueFalseTotal
if $response 0 0 0
563 }
564 5 return;
565 }
566  
567 sub _process_dns_mx {
568 0 ▶ my ($kernel,$self,$response) = @_[KERNEL,OBJECT,ARG0];
Subroutine _process_dns_mx: not called CC=4 SCAR=30.0
569 0 my $item = $response->{context};
570 0 ▶ unless ( $response->{response} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response->{"response"}) 0 0 0
571 0 ▶ if ( time() - $item->{ts} > 345600 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (time - $item->{"ts"} > 345600) 0 0 0
572 0 return;
573 }
574 0 push @{ $self->{_mail_queue} }, $item;
575 0 return;
576 }
577 0 my @answers = $response->{response}->answer();
578 0 my %mx = map { ( $_->exchange(), $_->preference() ) }
579 0 grep { $_->type() eq 'MX' } @answers;
580 0 my @mx = sort { $mx{$a} <=> $mx{$b} } keys %mx;
581 0 ▶ push @mx, $response->{host} unless scalar @mx;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @mx 0 0 0
582 0 $item->{mx} = \@mx;
583 0 $kernel->yield( '_smtp_send_mx', $item );
584 0 return;
585 }
586  
587 sub _smtp_send_mx {
588 0 ▶ my ($kernel,$self,$item) = @_[KERNEL,OBJECT,ARG0];
Subroutine _smtp_send_mx: not called CC=2 SCAR=17.9
589 0 $item->{count}++;
590 0 my $exchange = shift @{ $item->{mx} };
591 0 push @{ $item->{mx} }, $exchange;
592 0 $self->{_smtp_clients}++;
593 POE::Component::Client::SMTP->send(
594 From => $item->{from},
595 To => $item->{rcpt},
596 Body => $item->{msg},
597 Server => $exchange,
598 Context => $item,
599 Debug => $self->{smtpc_debug},
600 Timeout => $self->{time_out} || 300,
601 MyHostname => $self->{hostname},
602 0 ▶ SMTP_Success => '_smtp_send_success',
Condition0%0/2
$self->{'time_out'} || 300
l!l
00
MC/DC0%0/1
$self->{'time_out'} || 300
$self->{'time_out'}
Truth table0%0/2
A
A= $self->{'time_out'}
Aresult
11
00
603 SMTP_Failure => '_smtp_send_failure',
604 );
605 0 return;
606 }
607  
608 sub _smtp_send_relay {
609 0 ▶ my ($kernel,$self,$item) = @_[KERNEL,OBJECT,ARG0];
Subroutine _smtp_send_relay: not called CC=6 SCAR=37.4
610 0 $item->{count}++;
611 0 my %auth;
612 0 ▶ if ( $self->{relay_user} and $self->{relay_pass} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"relay_user"} and $self->{"relay_pass"}) 0 0 0
Condition0%0/3
$self->{"relay_user"} and $self->{"relay_pass"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"relay_user"} and $self->{"relay_pass"}
$self->{"relay_user"} $self->{"relay_pass"}
Truth table0%0/3
A and B
A= $self->{"relay_user"}B= $self->{"relay_pass"}
ABresult
0X0
100
111
613 $auth{mechanism} = $self->{relay_auth} || 'PLAIN',
614 $auth{user} = $self->{relay_user},
615 $auth{pass} = $self->{relay_pass},
616 0 ▶ }
Condition0%0/2
$self->{'relay_auth'} || 'PLAIN'
l!l
00
MC/DC0%0/1
$self->{'relay_auth'} || 'PLAIN'
$self->{'relay_auth'}
Truth table0%0/2
A
A= $self->{'relay_auth'}
Aresult
11
00
617 0 $self->{_smtp_clients}++;
618 POE::Component::Client::SMTP->send(
619 From => $item->{from},
620 To => $item->{rcpt},
621 Body => $item->{msg},
622 Server => $self->{relay},
623 Context => $item,
624 Timeout => $self->{time_out} || 300,
625 MyHostname => $self->{hostname},
626 0 ▶ SMTP_Success => '_smtp_send_success',
Branch: 1 branch
BranchTrueFalseTotal
scalar keys %auth ? : 0 0 0
Condition0%0/2
$self->{'time_out'} || 300
l!l
00
MC/DC0%0/1
$self->{'time_out'} || 300
$self->{'time_out'}
Truth table0%0/2
A
A= $self->{'time_out'}
Aresult
11
00
627 SMTP_Failure => '_smtp_send_failure',
628 ( scalar keys %auth ? ( Auth => \%auth ) : () ),
629 );
630 0 return;
631 }
632  
633 sub _smtp_send_success {
634 0 ▶ my ($kernel,$self,$item) = @_[KERNEL,OBJECT,ARG0];
Subroutine _smtp_send_success: not called CC=1 SCAR=6.9
635 0 $self->send_event( 'smtpd_send_success', $item->{uid} );
636 0 $kernel->delay_set( '_process_queue', 20 );
637 0 $self->{_smtp_clients}--;
638 0 return;
639 }
640  
641 sub _smtp_send_failure {
642 0 ▶ my ($kernel,$self,$item,$error) = @_[KERNEL,OBJECT,ARG0,ARG1];
Subroutine _smtp_send_failure: not called CC=4 SCAR=30.0
643 0 $self->send_event( 'smtpd_send_failed', $item->{uid}, $error );
644 0 $self->{_smtp_clients}--;
645 0 ▶ if ( $error->{SMTP_Server_Error} and $error->{SMTP_Server_Error} =~ /^5/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error->{"SMTP_Server_Error"} and $error->{"SMTP_Server_Error"} =~ /^5/) 0 0 0
Condition0%0/3
$error->{"SMTP_Server_Error"} and $error->{"SMTP_Server_Error"} =~ /^5/
!ll&&!rl&&r
000
MC/DC0%0/2
$error->{"SMTP_Server_Error"} and $error->{"SMTP_Server_Error"} =~ /^5/
$error->{"SMTP_Server_Error"} $error->{"SMTP_Server_Error"} =~ /^5/
Truth table0%0/3
A and B
A= $error->{"SMTP_Server_Error"}B= $error->{"SMTP_Server_Error"} =~ /^5/
ABresult
0X0
100
111
646 0 return;
647 }
648 0 ▶ if ( time() - $item->{ts} > 345600 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (time - $item->{"ts"} > 345600) 0 0 0
649 0 return;
650 }
651 0 push @{ $self->{_mail_queue} }, $item;
652 0 $kernel->delay_set( '_process_queue', 20 );
653 0 return;
654 }
655  
656 sub SMTPD_connection {
657 12 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_connection: called CC=3 SCAR=11.0
Pod undocumented
658 12 my $id = ${ $_[0] };
659 12 my $peeraddr = ${ $_[1] };
660 12 ▶ return PLUGIN_EAT_NONE unless $self->{handle_connects};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"handle_connects"} 0 12 12
661 12 ▶ unless ( $self->{dnsbl_enable} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'dnsbl_enable'}) { } 1 11 12
662 11 $self->send_to_client( $id, join( ' ', '220', $self->{hostname}, $self->{version}, 'ready' ) );
663 }
664 else {
665 1 $self->{_dnsbl}->lookup( session => $self->{session_id}, event => '_dnsbl', address => $peeraddr, _id => $id );
666 }
667 12 return PLUGIN_EAT_NONE;
668 }
669  
670 sub _dnsbl {
671 1 ▶ my ($kernel,$self,$data) = @_[KERNEL,OBJECT,ARG0];
Subroutine _dnsbl: called CC=4 SCAR=14.2
672 1 my $id = delete $data->{_id};
673 1 delete $data->{$_} for qw(event session);
674 1 my $to_client = join ' ', '220', $self->{hostname}, $self->{version}, 'ready';
675 1 ▶ if ( $data->{error} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{'error'}) { } 0 1 1
676 0 $self->{clients}->{ $id }->{dnsbl} = 'NXDOMAIN';
677 }
678 else {
679 1 $self->{clients}->{ $id }->{dnsbl} = $data->{response};
680 1 ▶ $to_client = '554 No SMTP service here' if $data->{response} ne 'NXDOMAIN';
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"response"} ne "NXDOMAIN" 0 1 1
681 }
682 1 $self->send_to_client( $id, $to_client );
683 1 $self->_send_event( 'smtpd_dnsbl', $id, $to_client, $data );
684 1 return;
685 }
686  
687 sub _sender_verify {
688 0 ▶ my ($kernel,$self,$data) = @_[KERNEL,OBJECT,ARG0];
Subroutine _sender_verify: not called CC=3 SCAR=24.8
689 0 ▶ return if $data->{error} and $data->{error} eq 'NOERROR';
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"error"} and $data->{"error"} eq "NOERROR" 0 0 0
Condition0%0/3
$data->{"error"} and $data->{"error"} eq "NOERROR"
!ll&&!rl&&r
000
MC/DC0%0/2
$data->{"error"} and $data->{"error"} eq "NOERROR"
$data->{"error"} $data->{"error"} eq "NOERROR"
Truth table0%0/3
A and B
A= $data->{"error"}B= $data->{"error"} eq "NOERROR"
ABresult
0X0
100
111
690 0 my $id = delete $data->{context};
691 0 $self->{clients}->{ $id }->{fverify} = $data->{error};
692 0 return;
693 }
694  
695 sub SMTPD_cmd_helo {
696 4 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_cmd_helo: called CC=2 SCAR=6.9
Pod undocumented
697 4 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 3 1 4
698 1 my $id = ${ $_[0] };
699 1 $self->send_to_client( $id, '250 OK' );
700 1 return PLUGIN_EAT_ALL;
701 }
702  
703 sub SMTPD_cmd_ehlo {
704 0 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_cmd_ehlo: not called CC=2 SCAR=17.9
Pod undocumented
705 0 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 0 0 0
706 0 my $id = ${ $_[0] };
707 0 $self->send_to_client( $id, '250 ' . $self->{hostname} . ' Hello [' . $self->{clients}->{ $id }->{peeraddr} . '], pleased to meet you' );
708 0 return PLUGIN_EAT_ALL;
709 }
710  
711 sub SMTPD_cmd_mail {
712 11 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_cmd_mail: called CC=10 SCAR=29.5
Pod undocumented
713 11 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 3 8 11
714 8 my $id = ${ $_[0] };
715 8 my $args = ${ $_[1] };
716 8 my $response;
717 8 ▶ if ( $self->{dnsbl_enable} and ( !$self->{clients}->{ $id }->{dnsbl} or $self->{clients}->{ $id }->{dnsbl} ne 'NXDOMAIN' ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'dnsbl_enable'} and !$self->{'clients'}{$id}{'dnsbl'} || $self->{'clients'}{$id}{'dnsbl'} ne 'NXDOMAIN') { } 0 8 8
elsif ($self->{'clients'}{$id}{'mail'}) { } 0 8 8
elsif (my($from) = $args =~ /^from:\s*<(.+)>/i) { } 8 0 8
Condition50%3/6
$self->{"dnsbl_enable"} and !$self->{"clients"}{$id}{"dnsbl"} || $self->{"clients"}{$id}{"dnsbl"} ne "NXDOMAIN"
!ll&&!rl&&r
710
not $self->{"clients"}{$id}{"dnsbl"} or $self->{"clients"}{$id}{"dnsbl"} ne "NXDOMAIN"
l!l&&r!l&&!r
001
MC/DC0%0/3
$self->{"dnsbl_enable"} and !$self->{"clients"}{$id}{"dnsbl"} || $self->{"clients"}{$id}{"dnsbl"} ne "NXDOMAIN"
$self->{"dnsbl_enable"} not $self->{"clients"}{$id}{"dnsbl"} $self->{"clients"}{$id}{"dnsbl"} ne "NXDOMAIN"
Truth table50%2/4
A and not(B) or C
A= $self->{"dnsbl_enable"}B= not $self->{"clients"}{$id}{"dnsbl"}C= $self->{"clients"}{$id}{"dnsbl"} ne "NXDOMAIN"
ABCresult
0XX0
1000
11X1
1011
718 0 $response = '503 bad sequence of commands';
719 }
720 elsif ( $self->{clients}->{ $id }->{mail} ) {
721 0 $response = '503 Sender already specified';
722 }
723 elsif ( my ($from) = $args =~ /^from:\s*<(.+)>/i ) {
724 8 $response = "250 <$from>... Sender OK";
725 8 $self->{clients}->{ $id }->{mail} = $from;
726 8 ▶ if ( $self->{sender_verify} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"sender_verify"}) 0 8 8
727 0 my $host = Email::Address->new(undef,$from,undef)->host();
728 my $response = $self->{resolver}->resolve(
729 0 event => '_sender_verify',
730 type => 'MX',
731 host => $host,
732 context => $id,
733 );
734 0 ▶ $poe_kernel->post( $self->{session_id}, '_sender_verify', $response ) if $response;
Branch: 1 branch
BranchTrueFalseTotal
if $response 0 0 0
735 }
736 }
737 else {
738 0 ▶ $args = '' unless $args;
Branch: 1 branch
BranchTrueFalseTotal
unless $args 0 0 0
739 0 $response = "501 Syntax error in parameters scanning '$args'";
740 }
741 8 $self->send_to_client( $id, $response );
742 8 return PLUGIN_EAT_ALL;
743 }
744  
745 sub SMTPD_cmd_rcpt {
746 15 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_cmd_rcpt: called CC=9 SCAR=27.4
Pod undocumented
747 15 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 3 12 15
748 12 my $id = ${ $_[0] };
749 12 my $args = ${ $_[1] };
750 12 my $response;
751 12 ▶ if ( !$self->{clients}->{ $id }->{mail} ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $self->{'clients'}{$id}{'mail'}) { } 2 10 12
elsif ($self->{'sender_verify'} and defined $self->{'clients'}{$id}{'fverify'}) { } 0 10 10
elsif (my($to) = $args =~ /^to:\s*<(.+)>/i) { } 10 0 10
752 2 $response = '503 Need MAIL before RCPT';
753 }
754 ▶ elsif ( $self->{sender_verify} and defined $self->{clients}->{ $id }->{fverify} ) {
Condition33%1/3
$self->{"sender_verify"} and defined $self->{"clients"}{$id}{"fverify"}
!ll&&!rl&&r
1000
MC/DC0%0/2
$self->{"sender_verify"} and defined $self->{"clients"}{$id}{"fverify"}
$self->{"sender_verify"} defined $self->{"clients"}{$id}{"fverify"}
Truth table33%1/3
A and B
A= $self->{"sender_verify"}B= defined $self->{"clients"}{$id}{"fverify"}
ABresult
0X0
100
111
755 0 my $fverify = uc $self->{clients}->{ $id }->{fverify};
756 0 ▶ if ( $fverify eq 'NXDOMAIN' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fverify eq 'NXDOMAIN') { } 0 0 0
757 0 $response = '550 Sender verify failed';
758 }
759 else {
760 0 $response = '451 Temporary local problem - please try later';
761 }
762 0 delete $self->{clients}->{ $id }->{mail};
763 0 delete $self->{clients}->{ $id }->{rcpt};
764 0 delete $self->{clients}->{ $id }->{buffer};
765 0 delete $self->{clients}->{ $id }->{fverify};
766 0 $self->_send_event( 'smtpd_fverify', $id, $response, $fverify );
767 }
768 elsif ( my ($to) = $args =~ /^to:\s*<(.+)>/i ) {
769 # TODO scan through $self->{domains} and reject as necessary.
770 10 ▶ unless ( $self->_recipient_domain( $to ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_recipient_domain($to)) { } 9 1 10
771 1 $response = "550 #5.1.0 Address rejected $to";
772 }
773 else {
774 9 $response = "250 <$to>... Recipient OK";
775 9 push @{ $self->{clients}->{ $id }->{rcpt} }, $to;
776 }
777 }
778 else {
779 0 ▶ $args = '' unless $args;
Branch: 1 branch
BranchTrueFalseTotal
unless $args 0 0 0
780 0 $response = "501 Syntax error in parameters scanning '$args'";
781 }
782 12 $self->send_to_client( $id, $response );
783 12 return PLUGIN_EAT_ALL;
784 }
785  
786 sub _recipient_domain {
787 10 ▶ my $self = shift;
Subroutine _recipient_domain: called CC=5 SCAR=16.2
788 10 ▶ return 1 unless scalar @{ $self->{domains} };
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"domains"};} 7 3 10
789 3 ▶ my $address = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
790 3 my $hostpart = ( split /\@/, $address )[-1];
791 3 ▶ return unless $hostpart;
Branch: 1 branch
BranchTrueFalseTotal
unless $hostpart 0 3 3
792 3 ▶ return 1 if grep { uc $_ eq uc $hostpart } @{ $self->{domains} };
Branch: 1 branch
BranchTrueFalseTotal
if grep {uc $_ eq uc $hostpart;} @{$$self{"domains"};} 2 1 3
793 1 return 0;
794 }
795  
796 sub SMTPD_cmd_data {
797 8 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_cmd_data: called CC=7 SCAR=26.6
Pod undocumented
798 8 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 3 5 8
799 5 my $id = ${ $_[0] };
800 5 my $response;
801 5 ▶ if ( !$self->{clients}->{ $id }->{mail} ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $self->{'clients'}{$id}{'mail'}) { } 0 5 5
elsif (not $self->{'clients'}{$id}{'rcpt'}) { } 0 5 5
elsif ($self->{'sender_verify'} and defined $self->{'clients'}{$id}{'fverify'}) { } 0 5 5
802 0 $response = '503 Need MAIL command';
803 }
804 elsif ( !$self->{clients}->{ $id }->{rcpt} ) {
805 0 $response = '503 Need RCPT (recipient)';
806 }
807 ▶ elsif ( $self->{sender_verify} and defined $self->{clients}->{ $id }->{fverify} ) {
Condition33%1/3
$self->{"sender_verify"} and defined $self->{"clients"}{$id}{"fverify"}
!ll&&!rl&&r
500
MC/DC0%0/2
$self->{"sender_verify"} and defined $self->{"clients"}{$id}{"fverify"}
$self->{"sender_verify"} defined $self->{"clients"}{$id}{"fverify"}
Truth table33%1/3
A and B
A= $self->{"sender_verify"}B= defined $self->{"clients"}{$id}{"fverify"}
ABresult
0X0
100
111
808 0 my $fverify = uc $self->{clients}->{ $id }->{fverify};
809 0 ▶ if ( $fverify eq 'NXDOMAIN' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fverify eq 'NXDOMAIN') { } 0 0 0
810 0 $response = '550 Sender verify failed';
811 }
812 else {
813 0 $response = '451 Temporary local problem - please try later';
814 }
815 0 delete $self->{clients}->{ $id }->{mail};
816 0 delete $self->{clients}->{ $id }->{rcpt};
817 0 delete $self->{clients}->{ $id }->{buffer};
818 0 delete $self->{clients}->{ $id }->{fverify};
819 0 $self->_send_event( 'smtpd_fverify', $id, $response, $fverify );
820 }
821 else {
822 5 $response = '354 Enter mail, end with "." on a line by itself';
823 5 $self->{clients}->{ $id }->{buffer} = [ ];
824 }
825 5 $self->send_to_client( $id, $response );
826 5 return PLUGIN_EAT_ALL;
827 }
828  
829 sub SMTPD_cmd_noop {
830 8 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_cmd_noop: called CC=2 SCAR=7.0
Pod undocumented
831 8 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 0 8 8
832 8 my $id = ${ $_[0] };
833 8 $self->send_to_client( $id, '250 OK' );
834 8 return PLUGIN_EAT_ALL;
835 }
836  
837 sub SMTPD_cmd_expn {
838 7 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_cmd_expn: called CC=2 SCAR=7.0
Pod undocumented
839 7 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 0 7 7
840 7 my $id = ${ $_[0] };
841 7 $self->send_to_client( $id, '502 Command not implemented; unsupported operation (EXPN)' );
842 7 return PLUGIN_EAT_ALL;
843 }
844  
845 sub SMTPD_cmd_vrfy {
846 7 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_cmd_vrfy: called CC=2 SCAR=7.0
Pod undocumented
847 7 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 0 7 7
848 7 my $id = ${ $_[0] };
849 7 $self->send_to_client( $id, '252 Cannot VRFY user, but will accept message for delivery' );
850 7 return PLUGIN_EAT_ALL;
851 }
852  
853 sub SMTPD_cmd_rset {
854 2 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_cmd_rset: called CC=3 SCAR=11.0
Pod undocumented
855 2 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 0 2 2
856 2 my $id = ${ $_[0] };
857 2 delete $self->{clients}->{$id}->{$_} for qw(mail rcpt buffer);
858 2 $self->send_to_client( $id, '250 Reset state' );
859 2 return PLUGIN_EAT_ALL;
860 }
861  
862 sub SMTPD_message {
863 5 ▶ my ($self,$smtpd) = splice @_, 0, 2;
Subroutine SMTPD_message: called CC=8 SCAR=20.8
Pod undocumented
864 5 ▶ return PLUGIN_EAT_NONE unless $self->{simple};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"simple"} 0 5 5
865 5 my $id = ${ $_[0] };
866 5 my $from = ${ $_[1] };
867 5 my $rcpt = ${ $_[2] };
868 5 my $buf = ${ $_[3] };
869 5 my $msg_id = Email::MessageID->new( host => $self->{hostname} );
870 5 my $uid = $msg_id->user();
871 3 unshift @{ $buf }, "Message-ID: " . $msg_id->in_brackets()
872 5 ▶ unless grep { /^Message-ID:/i } @{ $buf };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {/^Message-ID:/i;} @{$buf;} 3 2 5
873 4 unshift @{ $buf }, "Received: from Unknown [" . $self->{clients}->{ $id }->{peeraddr} . "] by " . $self->{hostname} . " " . $self->{version} . " with SMTP id $uid; " . strftime("%a, %d %b %Y %H:%M:%S %z", localtime)
874 5 ▶ unless $self->{origin};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"origin"} 4 1 5
875 5 $self->send_to_client( $id, "250 $uid Message accepted for delivery" );
876 5 my $email = Email::Simple->new( join "\r\n", @{ $buf } );
877 5 ▶ $email->header_set('Received') if $self->{origin};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"origin"} 1 4 5
878 5 ▶ my $subject = $email->header('Subject') || '';
Condition50%1/2
$email->header('Subject') || ''
l!l
50
MC/DC0%0/1
$email->header('Subject') || ''
$email->header('Subject')
Truth table50%1/2
A
A= $email->header('Subject')
Aresult
11
00
879 5 push @{ $self->{_mail_queue} }, { uid => $uid, from => $from, rcpt => $rcpt, msg => $email->as_string, ts => time(), subject => $subject };
880 5 $poe_kernel->post( $self->{session_id}, '_process_queue' );
881 5 ▶ $self->send_event( 'smtpd_message_queued', $id, $from, $rcpt, $uid, scalar @{ $buf }, $subject || '' );
Condition50%1/2
$subject || ''
l!l
50
MC/DC0%0/1
$subject || ''
$subject
Truth table50%1/2
A
A= $subject
Aresult
11
00
882 5 delete $self->{clients}->{$id}->{$_} for qw(mail rcpt buffer);
883 5 return PLUGIN_EAT_ALL;
884 }
885  
886 sub enqueue {
887 1 ▶ my $self = shift;
Subroutine enqueue: called CC=15 SCAR=35.3
Pod documented
888 1 my %item;
889 1 ▶ if ( ref $_[0] and ref $_[0] eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] and ref $_[0] eq 'HASH') { } 1 0 1
elsif (ref $_[0] and ref $_[0] eq 'ARRAY') { } 0 0 0
Condition33%1/3
ref $_[0] and ref $_[0] eq "HASH"
!ll&&!rl&&r
001
MC/DC0%0/2
ref $_[0] and ref $_[0] eq "HASH"
ref $_[0] ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= ref $_[0]B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
890 1 %item = %{ $_[0] };
891 }
892 ▶ elsif ( ref $_[0] and ref $_[0] eq 'ARRAY' ) {
Condition0%0/3
ref $_[0] and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_[0] and ref $_[0] eq "ARRAY"
ref $_[0] ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= ref $_[0]B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
893 0 %item = @{ $_[0] };
894 }
895 else {
896 0 %item = @_;
897 }
898 1 $item{lc $_} = delete $item{$_} for keys %item;
899 1 ▶ return unless $item{from};
Branch: 1 branch
BranchTrueFalseTotal
unless $item{"from"} 0 1 1
900 1 ▶ return unless $item{msg};
Branch: 1 branch
BranchTrueFalseTotal
unless $item{"msg"} 0 1 1
901 1 ▶ return unless $item{rcpt} and ref $item{rcpt} eq 'ARRAY' and scalar @{ $item{rcpt} };
Branch: 1 branch
BranchTrueFalseTotal
unless $item{"rcpt"} and ref $item{"rcpt"} eq "ARRAY" and scalar @{$item{"rcpt"};} 0 1 1
Condition40%2/5
$item{"rcpt"} and ref $item{"rcpt"} eq "ARRAY" and scalar @{$item{"rcpt"};}
!ll
01
$item{"rcpt"} and ref $item{"rcpt"} eq "ARRAY"
!ll&&!rl&&r
001
MC/DC0%0/2
$item{"rcpt"} and ref $item{"rcpt"} eq "ARRAY" and scalar @{$item{"rcpt"};}
$item{"rcpt"} ref $item{"rcpt"} eq "ARRAY"
Truth table33%1/3
A and B
A= $item{"rcpt"}B= ref $item{"rcpt"} eq "ARRAY"
ABresult
0X0
100
111
902 1 ▶ $item{ts} = time() unless $item{ts} and $item{ts} =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $item{"ts"} and $item{"ts"} =~ /^\d+$/ 1 0 1
Condition33%1/3
$item{"ts"} and $item{"ts"} =~ /^\d+$/
!ll&&!rl&&r
100
MC/DC0%0/2
$item{"ts"} and $item{"ts"} =~ /^\d+$/
$item{"ts"} $item{"ts"} =~ /^\d+$/
Truth table33%1/3
A and B
A= $item{"ts"}B= $item{"ts"} =~ /^\d+$/
ABresult
0X0
100
111
903 1 ▶ $item{uid} = Email::MessageID->new( host => $self->{hostname} )->user() unless $item{uid};
Branch: 1 branch
BranchTrueFalseTotal
unless $item{"uid"} 1 0 1
904 1 ▶ $item{subject} = '' unless $item{subject};
Branch: 1 branch
BranchTrueFalseTotal
unless $item{"subject"} 1 0 1
905 1 push @{ $self->{_mail_queue} }, \%item;
906 1 $poe_kernel->post( $self->{session_id}, '_process_queue' );
907 1 return 1;
908 }
909  
910 14 1;
911  
912  
913 __END__
↑ Summary SimpleSMTP/Constants.pm »