View | Details | Raw Unified | Return to bug 26705
Collapse All | Expand All

(-)a/Koha/Email.pm (-5 / +7 lines)
Lines 22-27 use Modern::Perl; Link Here
22
22
23
use Email::Valid;
23
use Email::Valid;
24
use Email::MessageID;
24
use Email::MessageID;
25
use List::Util qw(pairs);
26
25
use Koha::Exceptions;
27
use Koha::Exceptions;
26
28
27
use C4::Context;
29
use C4::Context;
Lines 153-163 sub send_or_die { Link Here
153
155
154
        my @recipients;
156
        my @recipients;
155
157
156
        # extract all recipient addresses from header
158
        my @headers = $self->email->header_str_pairs;
157
        foreach my $header ( 'To', 'Cc', 'Bcc' ) {
159
        foreach my $pair ( pairs @headers ) {
158
            push @recipients,
160
            my ( $header, $value ) = @$pair;
159
              map { $_->as_string }
161
            push @recipients, split (', ', $value)
160
              $self->email->header_obj->header_as_obj($header)->addresses;
162
                if grep { $_ eq $header } ('To', 'Cc', 'Bcc');
161
        }
163
        }
162
164
163
        # Remove the Bcc header
165
        # Remove the Bcc header
(-)a/t/Koha/Email.t (-4 / +4 lines)
Lines 226-236 subtest 'send_or_die() tests' => sub { Link Here
226
        'If explicitly passed, "to" is preserved' );
226
        'If explicitly passed, "to" is preserved' );
227
227
228
    $THE_email->send_or_die( { transport => $transport } );
228
    $THE_email->send_or_die( { transport => $transport } );
229
    my @to = sort @{ $args->{to} };
229
    is_deeply(
230
    is_deeply(
230
        $args->{to},
231
        [@to],
231
        [
232
        [
232
            'to@example.com',    'cc@example.com',
233
            'bcc_1@example.com', 'bcc_2@example.com',
233
            'bcc_1@example.com', 'bcc_2@example.com'
234
            'cc@example.com',    'to@example.com',
234
        ],
235
        ],
235
        'If "to" is not explicitly passed, extract recipients from headers'
236
        'If "to" is not explicitly passed, extract recipients from headers'
236
    );
237
    );
237
- 

Return to bug 26705