| 1 | # Copyrights 2001-2023 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This code is part of distribution Mail-Message. Meta-POD processed with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | package Mail::Message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | $VERSION = '3.013'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | use Mail::Message::Body::Multipart; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use Mail::Address; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # tests in t/55reply1r.t, demo in the examples/ directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | sub reply(@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reply: called CC=53 SCAR=51.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | my $body = $args{body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | ▶ | my $strip = !exists $args{strip_signature} || $args{strip_signature}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!exists $args{'strip_signature'} || $args{'strip_signature'}
MC/DC50%1/2
!exists $args{'strip_signature'} || $args{'strip_signature'}
!exists $args{'strip_signature'}
$args{'strip_signature'}
Truth table66%2/3
not(A) || B
A= !exists $args{'strip_signature'}B= $args{'strip_signature'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | my $include = $args{include} || 'INLINE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'include'} || 'INLINE'
MC/DC0%0/1
$args{'include'} || 'INLINE'
$args{'include'}
Truth table50%1/2
A
A= $args{'include'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | if($include eq 'NO') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | { # Throw away real body. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $body = Mail::Message::Body->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | (data => ["\n[The original message is not included]\n\n"]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | unless defined $body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ▶ | elsif($include eq 'INLINE' || $include eq 'ATTACH') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$include eq "INLINE" or $include eq "ATTACH"
MC/DC0%0/2
$include eq "INLINE" or $include eq "ATTACH"
$include eq "INLINE"
$include eq "ATTACH"
Truth table33%1/3
A or B
A= $include eq "INLINE"B= $include eq "ATTACH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | ▶ | unless(defined $body) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | { # text attachment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | $body = $self->body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | ▶ | $body = $body->part(0)->body if $body->isMultipart && $body->parts==1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$body->isMultipart and $body->parts == 1
MC/DC0%0/2
$body->isMultipart and $body->parts == 1
$body->isMultipart
$body->parts == 1
Truth table33%1/3
A and B
A= $body->isMultipartB= $body->parts == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | $body = $body->nested->body if $body->isNested; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | $body | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | = $strip && ! $body->isMultipart && !$body->isBinary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ? $body->decoded->stripSignature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ( pattern => $args{strip_signature} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | , max_lines => $args{max_signature} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | ▶ | : $body->decoded; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$strip and not $body->isMultipart and not $body->isBinary
$strip and not $body->isMultipart
MC/DC33%1/3
$strip and not $body->isMultipart and not $body->isBinary
$strip
not $body->isMultipart
not $body->isBinary
Truth table50%2/4
A and not(B) and not(C)
A= $stripB= not $body->isMultipartC= not $body->isBinary
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | ▶ | if($include eq 'INLINE' && $body->isMultipart) { $include = 'ATTACH' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$include eq "INLINE" and $body->isMultipart
MC/DC0%0/2
$include eq "INLINE" and $body->isMultipart
$include eq "INLINE"
$body->isMultipart
Truth table33%1/3
A and B
A= $include eq "INLINE"B= $body->isMultipart
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ▶ | elsif($include eq 'INLINE' && $body->isBinary) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$include eq "INLINE" and $body->isBinary
MC/DC0%0/2
$include eq "INLINE" and $body->isBinary
$include eq "INLINE"
$body->isBinary
Truth table33%1/3
A and B
A= $include eq "INLINE"B= $body->isBinary
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | { $include = 'ATTACH'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $body = Mail::Message::Body::Multipart->new(parts => [$body]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | ▶ | if($include eq 'INLINE') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { my $quote | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | = defined $args{quote} ? $args{quote} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | : exists $args{quote} ? undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | ▶ | : '> '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | ▶ | if(defined $quote) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | ▶ | { my $quoting = ref $quote ? $quote : sub {$quote . $_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | $body = $body->foreachLine($quoting); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | { $self->log(ERROR => "Cannot include reply source as $include."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # Collect header info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | my $mainhead = $self->toplevel->head; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # Where it comes from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | my $from = delete $args{From}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | ▶ | unless(defined $from) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 3 | { my @from = $self->to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | ▶ | $from = \@from if @from; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # To whom to send | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | my $to = delete $args{To} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | ▶ | || $mainhead->get('reply-to') || $mainhead->get('from'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
delete $args{'To'} || $mainhead->get('reply-to') || $mainhead->get('from')
delete $args{"To"} or $mainhead->get("reply-to")
MC/DC0%0/3
delete $args{'To'} || $mainhead->get('reply-to') || $mainhead->get('from')
delete $args{"To"}
$mainhead->get("reply-to")
$mainhead->get('from')
Truth table25%1/4
A or B || C
A= delete $args{"To"}B= $mainhead->get("reply-to")C= $mainhead->get('from')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | ▶ | defined $to or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # Add Cc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | my $cc = delete $args{Cc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | if(!defined $cc && $args{group_reply}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $cc and $args{"group_reply"}
MC/DC50%1/2
not defined $cc and $args{"group_reply"}
not defined $cc
$args{"group_reply"}
Truth table66%2/3
not(A) and B
A= not defined $ccB= $args{"group_reply"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | { my @cc = $self->cc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | ▶ | $cc = [ $self->cc ] if @cc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Create a subject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 3 | my $srcsub = delete $args{Subject}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | ▶ | my $subject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | = ! defined $srcsub ? $self->replySubject($self->subject) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | : ref $srcsub ? $srcsub->($self->subject) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | : $srcsub; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # Create a nice message-id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 3 | my $msgid = delete $args{'Message-ID'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | $msgid = "<$msgid>" if $msgid && $msgid !~ /^\s*\<.*\>\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$msgid and not $msgid =~ /^\s*\<.*\>\s*$/
MC/DC0%0/2
$msgid and not $msgid =~ /^\s*\<.*\>\s*$/
$msgid
not $msgid =~ /^\s*\<.*\>\s*$/
Truth table33%1/3
A and not(B)
A= $msgidB= not $msgid =~ /^\s*\<.*\>\s*$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # Thread information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 3 | my $origid = '<'.$self->messageId.'>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | my $refs = $mainhead->get('references'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # Prelude | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | my $prelude | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | = defined $args{prelude} ? $args{prelude} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | : exists $args{prelude} ? undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | ▶ | : [ $self->replyPrelude($to) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | ▶ | $prelude = Mail::Message::Body->new(data => $prelude) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $prelude and not builtin::blessed($prelude)
MC/DC50%1/2
defined $prelude and not builtin::blessed($prelude)
defined $prelude
not builtin::blessed($prelude)
Truth table66%2/3
A and not(B)
A= defined $preludeB= not builtin::blessed($prelude)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | if defined $prelude && ! blessed $prelude; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | my $postlude = $args{postlude}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 | ▶ | $postlude = Mail::Message::Body->new(data => $postlude) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $postlude and not builtin::blessed($postlude)
MC/DC0%0/2
defined $postlude and not builtin::blessed($postlude)
defined $postlude
not builtin::blessed($postlude)
Truth table66%2/3
A and not(B)
A= defined $postludeB= not builtin::blessed($postlude)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | if defined $postlude && ! blessed $postlude; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # Create the message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | my $total; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | ▶ | if($include eq 'NO') {$total = $body} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | elsif($include eq 'INLINE') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | { my $signature = $args{signature}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3 | ▶ | $signature = $signature->body | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $signature and $signature->isa("Mail::Message")
MC/DC0%0/2
defined $signature and $signature->isa("Mail::Message")
defined $signature
$signature->isa("Mail::Message")
Truth table33%1/3
A and B
A= defined $signatureB= $signature->isa("Mail::Message")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | if defined $signature && $signature->isa('Mail::Message'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 3 | ▶ | $total = $body->concatenate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ( $prelude, $body, $postlude | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | , (defined $signature ? "-- \n" : undef), $signature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 3 | ▶ | if($include eq 'ATTACH') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $intro = $prelude->concatenate | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ( $prelude | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | , [ "\n", "[Your message is attached]\n" ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | , $postlude | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | $total = Mail::Message::Body::Multipart->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ( parts => [ $intro, $body, $args{signature} ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 3 | ▶ | my $msgtype = $args{message_type} || 'Mail::Message'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'message_type'} || 'Mail::Message'
MC/DC0%0/1
$args{'message_type'} || 'Mail::Message'
$args{'message_type'}
Truth table50%1/2
A
A= $args{'message_type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | ▶ | my $reply = $msgtype->buildFromBody | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$from || 'Undisclosed senders:;'
MC/DC0%0/1
$from || 'Undisclosed senders:;'
$from
Truth table50%1/2
A
A= $from
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ( $total | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | , From => $from || 'Undisclosed senders:;' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | , To => $to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | , Subject => $subject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | , 'In-Reply-To' => $origid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | , References => ($refs ? "$refs $origid" : $origid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | my $newhead = $reply->head; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | ▶ | $newhead->set(Cc => $cc) if $cc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | ▶ | $newhead->set(Bcc => delete $args{Bcc}) if $args{Bcc}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | $newhead->add($_ => $args{$_}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | for sort grep /^[A-Z]/, keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # Ready | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | $self->log(PROGRESS => 'Reply created from '.$origid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | $self->label(replied => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | $reply; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # tests in t/35reply1rs.t | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | sub replySubject($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 24 | ▶ | { my ($thing, $subject) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replySubject: called CC=14 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 24 | ▶ | $subject = 'your mail' unless defined $subject && length $subject; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $subject and length $subject
MC/DC100%2/2
defined $subject and length $subject
defined $subject
length $subject
Truth table100%3/3
A and B
A= defined $subjectB= length $subject
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 24 | my @subject = split /\:/, $subject; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 24 | my $re_count = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # Strip multiple Re's from the start. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 24 | ▶ | while(@subject) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 38 | ▶ | { last if $subject[0] =~ /[A-QS-Za-qs-z][A-DF-Za-df-z]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 14 | for(shift @subject) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 14 | ▶ | { while( /\bRe(?:\[\s*(\d+)\s*\]|\b)/g ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 17 | ▶ | { $re_count += defined $1 ? $1 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # Strip multiple Re's from the end. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 24 | ▶ | if(@subject) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 24 | { for($subject[-1]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 24 | ▶ | { $re_count++ while s/\s*\(\s*(re|forw)\W*\)\s*$//i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # Create the new subject string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 24 | ▶ | my $text = (join ':', @subject) || 'your mail'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
join(':', @subject) || 'your mail'
MC/DC0%0/1
join(':', @subject) || 'your mail'
join(':', @subject)
Truth table50%1/2
A
A= join(':', @subject)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 24 | for($text) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 24 | { s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 24 | s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 24 | ▶ | $re_count==1 ? "Re: $text" : "Re[$re_count]: $text"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | sub replyPrelude($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | ▶ | { my ($self, $who) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replyPrelude: called CC=9 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | ▶ | $who = $who->[0] if ref $who eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | ▶ | my $user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | = !defined $who ? undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | : !ref $who ? (Mail::Address->parse($who))[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | : $who->isa('Mail::Message::Field') ? ($who->addresses)[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | : $who; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | ▶ | my $from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
ref $user and $user->isa("Mail::Address")
$user->name or $user->address or $user->format
$user->name or $user->address
MC/DC0%0/2
ref $user and $user->isa("Mail::Address")
ref $user
$user->isa("Mail::Address")
MC/DC0%0/3
$user->name or $user->address or $user->format
$user->name
$user->address
$user->format
Truth table33%1/3
A and B
A= ref $userB= $user->isa("Mail::Address")
Truth table25%1/4
A or B or C
A= $user->nameB= $user->addressC= $user->format
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | = ref $user && $user->isa('Mail::Address') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ? ($user->name || $user->address || $user->format) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | : 'someone'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | my $time = gmtime $self->timestamp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | "On $time, $from wrote:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||