Bugzilla – Attachment 126527 Details for
Bug 28729
Return-path header not set in emails
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28729: Make Koha::Email->send_or_die handle returnpath
Bug-28729-Make-KohaEmail-sendordie-handle-returnpa.patch (text/plain), 2.12 KB, created by
Martin Renvoize (ashimema)
on 2021-10-19 16:23:02 UTC
(
hide
)
Description:
Bug 28729: Make Koha::Email->send_or_die handle returnpath
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-10-19 16:23:02 UTC
Size:
2.12 KB
patch
obsolete
>From ac7bf57114b92f5c2987fd3ae8056698080aa1e7 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 19 Oct 2021 16:57:25 +0100 >Subject: [PATCH] Bug 28729: Make Koha::Email->send_or_die handle returnpath > >Koha used to rely on Mail::Sendmail for sending emails. As an SMTP >client, the library would extract the from address from the Sender >header to pass along in the MAIL FROM: field of the SMTP protocol [1]. > >This was overlooked when we moved to Email::Stuffer/Email::Simple and >there's a different behavior as it expects the envelope to be passed and >falls back to extracting the 'From' header when said envelope is not >found [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 {from} parameter is passed, it extracts the MAIL FROM >envelope from the Sender header, as Mail::Sendmail did, and calls >$self->SUPER::send_or_die with the right parameters. > >To test: >1. Apply the unit tests >2. Run: > $ kshell > k$ prove t/Koha/Email.t > => FAIL: Sender is not handled correctly! >3. Apply this patch >4. Repeat 2 > => SUCCESS: Tests pass! > The from parameter is correct! > No Sender header sent! >5. Sign off :-D > >[1] https://metacpan.org/dist/Mail-Sendmail/source/lib/Mail/Sendmail.pm#L284 >[2] https://metacpan.org/pod/Email::Sender::Manual::QuickStart#envelope-information >--- > Koha/Email.pm | 11 +++++++++++ > 1 file changed, 11 insertions(+) > >diff --git a/Koha/Email.pm b/Koha/Email.pm >index cac63763ab..c894764a1f 100644 >--- a/Koha/Email.pm >+++ b/Koha/Email.pm >@@ -177,6 +177,17 @@ sub send_or_die { > $args->{to} = \@recipients; > } > >+ unless ( $args->{from} ) { # don't do it if passed an explicit 'from' param >+ my @headers = $self->email->header_str_pairs; >+ foreach my $pair ( pairs @headers ) { >+ my ( $header, $value ) = @$pair; >+ $args->{from} = $value if $header eq 'Sender'; >+ } >+ >+ # Remove the Sender header >+ $self->email->header_str_set('Sender'); >+ } >+ > $self->SUPER::send_or_die($args); > } > >-- >2.20.1
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 28729
:
126436
|
126526
|
126527
|
127016
|
127017
|
127085
|
127086
|
127094