Browse Source

Bug 26705: (QA follow-up) Do not rely on latest Email::MIME

This patch makes the implementation use lower-level methods to deal with
headers. So the Email::MIME library in Debian 9 works.

Params are sorted for testing purposes.

To test:
1. Apply this patch
2. Run the tests
=> SUCCESS: Things pass in D9+
3. Sign off :-D

Thanks Kyle!

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Tomás Cohen Arazi 2 years ago
committed by Jonathan Druart
parent
commit
539c9e5c9b
  1. 12
      Koha/Email.pm
  2. 7
      t/Koha/Email.t

12
Koha/Email.pm

@ -22,6 +22,8 @@ use Modern::Perl;
use Email::Valid;
use Email::MessageID;
use List::Util qw(pairs);
use Koha::Exceptions;
use C4::Context;
@ -153,11 +155,11 @@ sub send_or_die {
my @recipients;
# extract all recipient addresses from header
foreach my $header ( 'To', 'Cc', 'Bcc' ) {
push @recipients,
map { $_->as_string }
$self->email->header_obj->header_as_obj($header)->addresses;
my @headers = $self->email->header_str_pairs;
foreach my $pair ( pairs @headers ) {
my ( $header, $value ) = @$pair;
push @recipients, split (', ', $value)
if grep { $_ eq $header } ('To', 'Cc', 'Bcc');
}
# Remove the Bcc header

7
t/Koha/Email.t

@ -226,11 +226,12 @@ subtest 'send_or_die() tests' => sub {
'If explicitly passed, "to" is preserved' );
$THE_email->send_or_die( { transport => $transport } );
my @to = sort @{ $args->{to} };
is_deeply(
$args->{to},
[@to],
[
'to@example.com', 'cc@example.com',
'bcc_1@example.com', 'bcc_2@example.com'
'bcc_1@example.com', 'bcc_2@example.com',
'cc@example.com', 'to@example.com',
],
'If "to" is not explicitly passed, extract recipients from headers'
);

Loading…
Cancel
Save