Bugzilla – Attachment 118714 Details for
Bug 26705
System preference NoticeBcc not working
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26705: Make Koha::Email->send_or_die handle Bcc
Bug-26705-Make-KohaEmail-sendordie-handle-Bcc.patch (text/plain), 2.64 KB, created by
Kyle M Hall (khall)
on 2021-03-24 10:41:16 UTC
(
hide
)
Description:
Bug 26705: Make Koha::Email->send_or_die handle Bcc
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-03-24 10:41:16 UTC
Size:
2.64 KB
patch
obsolete
>From 90060e70a497fc24dc7fc116502d8c8108bf042b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 23 Mar 2021 10:57:13 -0300 >Subject: [PATCH] Bug 26705: Make Koha::Email->send_or_die handle Bcc > >Koha used to rely on Mail::Sendmail for sending emails. As an SMTP >client, the library took the job of extracting Bcc headers (and removing >them) to pass them along with the recipients listed on To: and Cc: to >the SMTP protocol in the form of RCPT TO: lines. [1] > >This was overlooked when we moved to Email::Stuffer/Email::Simple and >there's a different behavior, that is a design decision [2]. > >This patchset re-introduces the behavior from Mail::Sendmail by >overriding the send_or_die method locally (in Koha::Email) and doing the >right thing. > >Unless an explicit {to} parameter is passed, it extracts the recipients >from the headers, as Mail::Sendmail does, and calls >$self->SUPER::send_or_die with the right parameters. > >To test: >1. Apply the regression tests >2. Run: > $ kshell > k$ prove t/Koha/Email.t >=> FAIL: Bcc is not handled correctly! >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! The recipients list is correct! No Bcc header >sent! >5. Sign off :-D > >[1] https://metacpan.org/release/Mail-Sendmail/source/lib/Mail/Sendmail.pm#L331 >[2] https://metacpan.org/pod/Email::Sender::Manual::QuickStart#Hey,-where's-my-Bcc-support > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Email.pm | 34 ++++++++++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > >diff --git a/Koha/Email.pm b/Koha/Email.pm >index e91a49e402..450e4015cd 100644 >--- a/Koha/Email.pm >+++ b/Koha/Email.pm >@@ -136,4 +136,38 @@ sub create { > return $email; > } > >+=head3 send_or_die >+ >+ $email->send_or_die({ transport => $transport [, $args] }); >+ >+Overloaded Email::Stuffer I<send_or_die> method, that takes care of Bcc handling. >+Bcc is removed from the message headers, and included in the recipients list to be >+passed to I<send_or_die>. >+ >+=cut >+ >+sub send_or_die { >+ my ( $self, $args ) = @_; >+ >+ unless ( $args->{to} ) { # don't do it if passed an explicit 'to' param >+ >+ 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; >+ } >+ >+ # Remove the Bcc header >+ $self->email->header_str_set('Bcc'); >+ >+ # Tweak $args >+ $args->{to} = \@recipients; >+ } >+ >+ $self->SUPER::send_or_die($args); >+} >+ > 1; >-- >2.24.1 (Apple Git-126)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26705
:
118659
|
118660
|
118663
|
118664
|
118665
|
118704
|
118705
|
118713
| 118714 |
118715
|
118716