Simple.pm

filter: Statementstmt 45.4% 94 / 207 Branchbran 31.1% 28 / 90 Conditioncond 20.9% 13 / 62 MC/DCmcdc 10.0% 3 / 30 Subroutinesub 72.0% 18 / 25 Podpod 50.0% 1 / 2 totaltotal 37.7% 157 / 416 CC 74 SCAR 43.3
CC
74
Cov
38%
_set_or_add
240.0
_add_arg
156.0
_process_template
132.0
CRAP 75.7
↑ Summary Simple/HTML/Template.pm »
1 package Mail::Builder::Simple;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Mail::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Email::Sender::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Email::Valid;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp qw/cluck/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Config::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Module::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use base 'Mail::Builder';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use 5.008_008;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 our $VERSION = '0.16';
17  
18 2 ▶sub new {
Subroutine new: called CC=3 SCAR=11.1
Pod documented
19 2 my @params = @_;
20 2 my $class = shift @params;
21 2 ▶ my $args = ref( $params[0] ) eq 'HASH' ? $params[0] : {@params}
Branch: 2 branches
BranchTrueFalseTotal
my $args = ref $params[0] eq "HASH" ? $params[0] : {@params} or cluck("Can't create mail object. Invalid parameters hash") 2 0 2
ref $params[0] eq 'HASH' ? : 0 2 2
22 or cluck 'Can\'t create mail object. Invalid parameters hash';
23  
24 2 my $self = $class->SUPER::new();
25 2 bless $self, $class;
26  
27 2 my @fields = qw/from reply organization returnpath sender priority
28 subject plaintext htmltext language to cc bcc attachment image mailer/;
29  
30 2 $self->{mail_fields} = join q{|}, @fields;
31  
32 2 $self->_add_args($args);
33  
34 2 return bless $self, $class;
35 }
36  
37 2 ▶sub _add_args {
Subroutine _add_args: called CC=8 SCAR=26.2
38 2 my @params = @_;
39 2 my $self = shift @params;
40 2 ▶ my $args = ref( $params[0] ) eq 'HASH' ? $params[0] : {@params}
Branch: 2 branches
BranchTrueFalseTotal
my $args = ref $params[0] eq "HASH" ? $params[0] : {@params} or return 2 0 2
ref $params[0] eq 'HASH' ? : 2 0 2
41 or return;
42  
43 2 ▶ if ( $args->{mail_client} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"mail_client"}) 0 2 2
44 0 $self->{mail_client} = $args->{mail_client};
45 }
46  
47 2 ▶ if ( $args->{template_args} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"template_args"}) 0 2 2
48 0 $self->{template_args} = $args->{template_args};
49 }
50  
51 2 ▶ if ( $args->{template_vars} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"template_vars"}) 0 2 2
52 0 $self->{template_vars} = $args->{template_vars};
53 }
54  
55 2 ▶ if ( my $config_file = $args->{config_file} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $config_file = $args->{"config_file"}) 0 2 2
56 0 my $conf = Config::Any->load_files(
57 {
58 files => [$config_file],
59 use_ext => 1,
60 driver_args => { General => { -UTF8 => 1 } },
61 }
62 );
63  
64 0 delete $args->{config_file};
65  
66 0 $self->_add_args( $conf->[0]->{$config_file} );
67 }
68  
69 2 foreach my $field ( sort keys %{$args} ) {
70 0 $self->_add_arg( $args, $field );
71 }
72  
73 2 return 1;
74 }
75  
76 0 ▶sub _add_arg {
Subroutine _add_arg: not called CC=12 SCAR=50.5
77 0 my ( $self, $args, $field ) = @_;
78  
79 0 ▶ return if $field !~ /^(?:$self->{mail_fields})$/smox;
Branch: 1 branch
BranchTrueFalseTotal
unless $field =~ /^(?:$self->{"mail_fields"})$/mosx 0 0 0
80  
81 0 my $value = $args->{$field};
82  
83 #If the value is an arrayref
84 0 ▶ if ( $value and ref($value) eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value and ref $value eq 'ARRAY') { } 0 0 0
elsif ($value and not ref $value) { } 0 0 0
Condition0%0/3
$value and ref $value eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$value and ref $value eq "ARRAY"
$value ref $value eq "ARRAY"
Truth table0%0/3
A and B
A= $valueB= ref $value eq "ARRAY"
ABresult
0X0
100
111
85  
86 #There are more items
87 0 ▶ if ( $value->[0] and $value->[0] eq 'MORE' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($value->[0] and $value->[0] eq 'MORE') { } 0 0 0
elsif ($value->[0] and ref $value->[0] eq 'ARRAY') { } 0 0 0
elsif ($value->[0] and not ref $value->[0]) { } 0 0 0
Condition0%0/3
$value->[0] and $value->[0] eq "MORE"
!ll&&!rl&&r
000
MC/DC0%0/2
$value->[0] and $value->[0] eq "MORE"
$value->[0] $value->[0] eq "MORE"
Truth table0%0/3
A and B
A= $value->[0]B= $value->[0] eq "MORE"
ABresult
0X0
100
111
88 0 shift @{$value};
89 0 $self->_process_array( $args, $field, $value );
90 }
91  
92 #There are more items
93 ▶ elsif ( $value->[0] and ref( $value->[0] ) eq 'ARRAY' ) {
Condition0%0/3
$value->[0] and ref $value->[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$value->[0] and ref $value->[0] eq "ARRAY"
$value->[0] ref $value->[0] eq "ARRAY"
Truth table0%0/3
A and B
A= $value->[0]B= ref $value->[0] eq "ARRAY"
ABresult
0X0
100
111
94 0 $self->_process_array( $args, $field, $value );
95 }
96  
97 #There is an item with one or more fields
98 ▶ elsif ( $value->[0] and not ref( $value->[0] ) ) {
Condition0%0/3
$value->[0] and not ref $value->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$value->[0] and not ref $value->[0]
$value->[0] not ref $value->[0]
Truth table0%0/3
A and not(B)
A= $value->[0]B= not ref $value->[0]
ABresult
0X0
100
111
99 0 $self->_process_item( $args, $field, $value );
100 }
101 else {
102 0 cluck 'Items inside arrayref should be scalar/arrayref.';
103 }
104 }
105  
106 #The value is a scalar
107 ▶ elsif ( $value and not ref $value ) {
Condition0%0/3
$value and not ref $value
!ll&&!rl&&r
000
MC/DC0%0/2
$value and not ref $value
$value not ref $value
Truth table0%0/3
A and not(B)
A= $valueB= not ref $value
ABresult
0X0
100
111
108 0 $self->_set_or_add( $field, $value );
109 }
110 else {
111 0 cluck "Value for $field should be scalar/an arrayref";
112 }
113  
114 0 return 1;
115 }
116  
117 0 ▶sub _process_array {
Subroutine _process_array: not called CC=2 SCAR=17.9
118 0 my ( $self, $args, $field, $value ) = @_;
119  
120 0 foreach my $item ( @{$value} ) {
121 0 $self->_process_item( $args, $field, $item );
122 }
123  
124 0 return 1;
125 }
126  
127 0 ▶sub _process_item {
Subroutine _process_item: not called CC=4 SCAR=30.0
128 0 my ( $self, $args, $field, $item ) = @_;
129  
130 #This item is an arrayref
131 0 ▶ if ( ref($item) eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $item eq 'ARRAY') { } 0 0 0
elsif (not ref $item) { } 0 0 0
132  
133 #This item is a template
134 0 ▶ if ( $item->[-1] =~ /^:(.+)/smox ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item->[-1] =~ /^:(.+)/mosx) { } 0 0 0
135 0 my $result = $self->_process_template( $args, $item, $field );
136 0 $self->_set_or_add( $field, $result );
137 }
138  
139 #It is not a template
140 else {
141 0 $self->_set_or_add( $field, @{$item} );
142 }
143 }
144  
145 #It is a scalar
146 elsif ( !ref $item ) {
147 0 $self->_set_or_add( $field, $item );
148 }
149 else {
150 0 cluck 'The elements of the array can be just scalars.';
151 }
152  
153 0 return 1;
154 }
155  
156 0 ▶sub _process_template {
Subroutine _process_template: not called CC=11 SCAR=48.8
157 0 my ( $self, $args, $item, $field ) = @_;
158  
159 0 my $type = substr $item->[-1], 1;
160 0 ( $type, my $source ) = split /-/smx, $type;
161 0 ▶ $source ||= 'file';
Condition0%0/2
$source ||= "file"
l!l
00
MC/DC0%0/1
$source ||= "file"
$source
Truth table0%0/2
A
A= $source
Aresult
11
00
162 0 delete $item->[-1];
163  
164 #Get and overwrite template_args
165 0 my $template_args = $self->{template_args};
166 0 ▶ if ( $args->{template_args} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"template_args"}) 0 0 0
167 0 foreach ( keys %{ $args->{template_args} } ) {
168 0 $template_args->{$_} = $args->{template_args}->{$_};
169 }
170 }
171  
172 #If this template has its own settings:
173 0 ▶ if ( ref( $item->[-1] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item->[-1] eq "HASH") 0 0 0
174 0 my $template_settings = pop @{$item};
175 0 foreach ( keys %{$template_settings} ) {
176  
177 #Insert and overwrite the new template settings:
178 0 $template_args->{$_} = $template_settings->{$_};
179 }
180 }
181  
182 #Get and overwrite template_vars
183 0 my $template_vars = $self->{template_vars};
184 0 ▶ if ( $args->{template_vars} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"template_vars"}) 0 0 0
185 0 foreach ( keys %{ $args->{template_vars} } ) {
186 0 $template_vars->{$_} = $args->{template_vars}->{$_};
187 }
188 }
189  
190 #If this template has its own variables:
191 0 ▶ if ( ref( $item->[-1] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item->[-1] eq "HASH") 0 0 0
192 0 my $template_variables = pop @{$item};
193 0 foreach ( keys %{$template_variables} ) {
194  
195 #Insert and overwrite the template vars:
196 0 $template_vars->{$_} = $template_variables->{$_};
197 }
198 }
199  
200 0 load "Mail::Builder::Simple::$type";
201  
202 0 my $t =
203 "Mail::Builder::Simple::$type"->new( $template_args, $template_vars );
204  
205 0 $item->[0] = $t->process( $item->[0], $source );
206  
207 0 ▶ if ( $field eq 'attachment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($field eq 'attachment') { } 0 0 0
208 0 return Mail::Builder::Attachment->new( \$item->[0], $item->[1], $item->[2] );
209 }
210 else {
211 0 return $item;
212 }
213 }
214  
215 0 ▶sub _set_or_add {
Subroutine _set_or_add: not called CC=15 SCAR=54.8
216 0 my ( $self, $field, @value ) = @_;
217  
218 0 ▶ return if not $self->_check_email_valid( $field, @value );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_check_email_valid($field, @value) 0 0 0
219  
220 0 ▶ if ( $field eq 'from'
Branch: 2 branches
BranchTrueFalseTotal
if ($field eq 'from' or $field eq 'reply' or $field eq 'organization' or $field eq 'returnpath' or $field eq 'sender' or $field eq 'priority' or $field eq 'subject' or $field eq 'language' or $field eq 'mailer') { } 0 0 0
elsif ($field eq 'plaintext' or $field eq 'htmltext') { } 0 0 0
Condition0%0/24
$field eq "from" or $field eq "reply" or $field eq "organization" or $field eq "returnpath" or $field eq "sender" or $field eq "priority" or $field eq "subject" or $field eq "language" or $field eq "mailer"
l!l&&r!l&&!r
000
$field eq "from" or $field eq "reply" or $field eq "organization" or $field eq "returnpath" or $field eq "sender" or $field eq "priority" or $field eq "subject" or $field eq "language"
l!l&&r!l&&!r
000
$field eq "from" or $field eq "reply" or $field eq "organization" or $field eq "returnpath" or $field eq "sender" or $field eq "priority" or $field eq "subject"
l!l&&r!l&&!r
000
$field eq "from" or $field eq "reply" or $field eq "organization" or $field eq "returnpath" or $field eq "sender" or $field eq "priority"
l!l&&r!l&&!r
000
$field eq "from" or $field eq "reply" or $field eq "organization" or $field eq "returnpath" or $field eq "sender"
l!l&&r!l&&!r
000
$field eq "from" or $field eq "reply" or $field eq "organization" or $field eq "returnpath"
l!l&&r!l&&!r
000
$field eq "from" or $field eq "reply" or $field eq "organization"
l!l&&r!l&&!r
000
$field eq "from" or $field eq "reply"
l!l&&r!l&&!r
000
MC/DC0%0/9
$field eq "from" or $field eq "reply" or $field eq "organization" or $field eq "returnpath" or $field eq "sender" or $field eq "priority" or $field eq "subject" or $field eq "language" or $field eq "mailer"
$field eq "from" $field eq "reply" $field eq "organization" $field eq "returnpath" $field eq "sender" $field eq "priority" $field eq "subject" $field eq "language" $field eq "mailer"
Truth table0%0/10
A or B or C or D or E or F or G or H or I
A= $field eq "from"B= $field eq "reply"C= $field eq "organization"D= $field eq "returnpath"E= $field eq "sender"F= $field eq "priority"G= $field eq "subject"H= $field eq "language"I= $field eq "mailer"
ABCDEFGHIresult
1XXXXXXXX1
01XXXXXXX1
001XXXXXX1
0001XXXXX1
00001XXXX1
000001XXX1
0000001XX1
00000001X1
0000000011
0000000000
221 or $field eq 'reply'
222 or $field eq 'organization'
223 or $field eq 'returnpath'
224 or $field eq 'sender'
225 or $field eq 'priority'
226 or $field eq 'subject'
227 or $field eq 'language'
228 or $field eq 'mailer' )
229 {
230 0 $self->$field(@value);
231 }
232 ▶ elsif ( $field eq 'plaintext' or $field eq 'htmltext' ) {
Condition0%0/3
$field eq "plaintext" or $field eq "htmltext"
l!l&&r!l&&!r
000
MC/DC0%0/2
$field eq "plaintext" or $field eq "htmltext"
$field eq "plaintext" $field eq "htmltext"
Truth table0%0/3
A or B
A= $field eq "plaintext"B= $field eq "htmltext"
ABresult
1X1
011
000
233 0 ▶ if ( ref( $value[0] ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value[0] eq 'ARRAY') { } 0 0 0
234 0 $self->$field( $value[0][0] );
235 }
236 else {
237 0 $self->$field( $value[0] );
238 }
239 }
240 else {
241 0 ▶ if ( $self->$field ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->$field) { } 0 0 0
242 0 $self->$field->add(@value);
243 }
244 else {
245 0 $self->$field(@value);
246 }
247 }
248  
249 0 return 1;
250 }
251  
252 2 ▶sub _check_email_valid {
Subroutine _check_email_valid: called CC=8 SCAR=23.1
253 2 my ( $self, $field, @value ) = @_;
254  
255 2 ▶ if ( $field eq 'from'
Branch: 1 branch
BranchTrueFalseTotal
if ($field eq "from" or $field eq "to" or $field eq "cc" or $field eq "bcc" or $field eq "reply" or $field eq "returnpath") 1 1 2
Condition66%10/15
$field eq "from" or $field eq "to" or $field eq "cc" or $field eq "bcc" or $field eq "reply" or $field eq "returnpath"
l!l&&r!l&&!r
101
$field eq "from" or $field eq "to" or $field eq "cc" or $field eq "bcc" or $field eq "reply"
l!l&&r!l&&!r
101
$field eq "from" or $field eq "to" or $field eq "cc" or $field eq "bcc"
l!l&&r!l&&!r
101
$field eq "from" or $field eq "to" or $field eq "cc"
l!l&&r!l&&!r
101
$field eq "from" or $field eq "to"
l!l&&r!l&&!r
101
MC/DC16%1/6
$field eq "from" or $field eq "to" or $field eq "cc" or $field eq "bcc" or $field eq "reply" or $field eq "returnpath"
$field eq "from" $field eq "to" $field eq "cc" $field eq "bcc" $field eq "reply" $field eq "returnpath"
Truth table28%2/7
A or B or C or D or E or F
A= $field eq "from"B= $field eq "to"C= $field eq "cc"D= $field eq "bcc"E= $field eq "reply"F= $field eq "returnpath"
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
256 or $field eq 'to'
257 or $field eq 'cc'
258 or $field eq 'bcc'
259 or $field eq 'reply'
260 or $field eq 'returnpath' )
261 {
262 1 ▶ if ( !Email::Valid->address( $value[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("Email::Valid"->address($value[0])) 0 1 1
263 0 warn "Bad email address: $value[0]";
264 0 return;
265 }
266 }
267  
268 2 return 1;
269 }
270  
271 0 ▶sub sendmail {
Subroutine sendmail: not called CC=4 SCAR=30.0
Pod undocumented
272 0 my @params = @_;
273 0 my $self = shift @params;
274 0 ▶ my $args = ref( $params[0] ) eq 'HASH' ? $params[0] : {@params}
Branch: 2 branches
BranchTrueFalseTotal
my $args = ref $params[0] eq "HASH" ? $params[0] : {@params} or cluck("Can't send mail. Invalid parameters hash") 0 0 0
ref $params[0] eq 'HASH' ? : 0 0 0
275 or cluck 'Can\'t send mail. Invalid parameters hash';
276  
277 #Add message fields:
278 0 $self->_add_args($args);
279  
280 #Create the email message
281 0 my $entity = $self->build_message;
282  
283 #Add custom headers if there are:
284 0 $self->_add_custom_headers( $entity, $args );
285  
286 0 my $mail_client = $self->{mail_client};
287  
288 0 my $mailer = $self->_load_mailer($mail_client);
289  
290 0 my $mailer_args = $self->_mailer_args($mail_client);
291  
292 #Accept the old keys for compatibility with older versions:
293 0 $mailer_args = $self->_asure_compatibility($mailer_args);
294  
295 #If the mailer_args contains other addresses to send the email to
296 #than the ones from the email:
297 0 my $different_addresses = $self->_different_email_addresses($mailer_args);
298  
299 #For sending with send() or try_to_send()
300 0 my $transport = $mailer->new( %{$mailer_args} );
301  
302 0 ▶ if ( $mail_client->{live_on_error} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mail_client->{'live_on_error'}) { } 0 0 0
303 Email::Sender::Simple->try_to_send( $entity->stringify,
304 0 { transport => $transport, %{$different_addresses} } );
305 }
306 else {
307 Email::Sender::Simple->send( $entity->stringify,
308 0 { transport => $transport, %{$different_addresses} } );
309 }
310  
311 #Reset To, Cc and BcC:
312 0 $self->to->reset;
313 0 $self->cc->reset;
314 0 $self->bcc->reset;
315  
316 0 return 1;
317 }
318  
319 2 *send = \&sendmail;
320  
321 0 ▶sub _add_custom_headers {
Subroutine _add_custom_headers: not called CC=3 SCAR=24.8
322 0 my ( $self, $entity, $args ) = @_;
323  
324 0 foreach my $field ( keys %{$args} ) {
325 0 ▶ next if $field =~ /^(?:$self->{mail_fields})$/smox;
Branch: 1 branch
BranchTrueFalseTotal
if $field =~ /^(?:$self->{"mail_fields"})$/mosx 0 0 0
326  
327 $entity->head->replace( $field,
328 0 Encode::encode( 'MIME-Header', $args->{$field} ) );
329 }
330  
331 0 return 1;
332 }
333  
334 2 ▶sub _load_mailer {
Subroutine _load_mailer: called CC=4 SCAR=14.1
335 2 my ( $self, $mail_client ) = @_;
336  
337 2 my $mailer;
338  
339 2 ▶ if ($mail_client) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mail_client) 2 0 2
340 2 $mailer = $mail_client->{mailer};
341 }
342  
343 2 ▶ if ( !$mailer ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mailer) 0 2 2
344 0 $mailer = 'Sendmail';
345 }
346  
347 2 ▶ if ( $mailer !~ /^Email::Sender::Transport/smox ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mailer =~ /^Email::Sender::Transport/mosx) 1 1 2
348 1 $mailer = 'Email::Sender::Transport::' . $mailer;
349 }
350  
351 2 load $mailer;
352  
353 2 return $mailer;
354 }
355  
356 1 ▶sub _mailer_args {
Subroutine _mailer_args: called CC=3 SCAR=12.0
357 1 my ( $self, $mail_client ) = @_;
358  
359 1 my %mailer_args = ();
360 1 ▶ if ( ref( $mail_client->{mailer_args} ) eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $mail_client->{'mailer_args'} eq 'HASH') { } 0 1 1
elsif (ref $mail_client->{'mailer_args'} eq 'ARRAY') { } 1 0 1
361 0 %mailer_args = %{ $mail_client->{mailer_args} };
362 }
363 elsif ( ref( $mail_client->{mailer_args} ) eq 'ARRAY' ) {
364 1 %mailer_args = @{ $mail_client->{mailer_args} };
365 }
366  
367 1 return \%mailer_args;
368 }
369  
370 4 ▶sub _asure_compatibility {
Subroutine _asure_compatibility: called CC=6 SCAR=17.9
371 4 my ( $self, $mailer_args ) = @_;
372  
373 4 ▶ if ( $mailer_args->{Host} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mailer_args->{"Host"}) 1 3 4
374 1 $mailer_args->{host} = delete $mailer_args->{Host};
375 }
376  
377 4 ▶ if ( $mailer_args->{username} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mailer_args->{"username"}) 1 3 4
378 1 $mailer_args->{sasl_username} = $mailer_args->{username};
379 }
380  
381 4 ▶ if ( $mailer_args->{password} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mailer_args->{"password"}) 1 3 4
382 1 $mailer_args->{sasl_password} = $mailer_args->{password};
383 }
384  
385 #Add the port if it was provided as host:port
386 4 ▶ if ( $mailer_args->{host} and $mailer_args->{host} =~ /:(\d+)$/smx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mailer_args->{"host"} and $mailer_args->{"host"} =~ /:(\d+)$/msx) 1 3 4
Condition100%3/3
$mailer_args->{"host"} and $mailer_args->{"host"} =~ /:(\d+)$/msx
!ll&&!rl&&r
211
MC/DC100%2/2
$mailer_args->{"host"} and $mailer_args->{"host"} =~ /:(\d+)$/msx
$mailer_args->{"host"} $mailer_args->{"host"} =~ /:(\d+)$/msx
Truth table100%3/3
A and B
A= $mailer_args->{"host"}B= $mailer_args->{"host"} =~ /:(\d+)$/msx
ABresult
0X0
100
111
387 1 my $port = $1;
388 1 $mailer_args->{host} =~ s/:\d+$//smx;
389 1 $mailer_args->{port} = $port;
390 }
391  
392 4 return $mailer_args;
393 }
394  
395 1 ▶sub _different_email_addresses {
Subroutine _different_email_addresses: called CC=4 SCAR=14.2
396 1 my ( $self, $mailer_args ) = @_;
397  
398 1 my %different_addresses;
399  
400 1 ▶ if ( $mailer_args->{to} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mailer_args->{"to"}) 1 0 1
401 1 $different_addresses{to} = delete $mailer_args->{to};
402 }
403  
404 1 ▶ if ( $mailer_args->{cc} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mailer_args->{"cc"}) 1 0 1
405 1 $different_addresses{cc} = delete $mailer_args->{cc};
406 }
407  
408 1 ▶ if ( $mailer_args->{from} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mailer_args->{"from"}) 1 0 1
409 1 $different_addresses{from} = delete $mailer_args->{from};
410 }
411  
412 1 return \%different_addresses;
413 }
414  
415 2 1;
416  
417 __END__
↑ Summary Simple/HTML/Template.pm »