From 02cbbcce283e2fc06ec4830ae3b866d1702e4860 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 18 Oct 2021 14:44:48 +0100 Subject: [PATCH] Bug 28729: Reverse 'sender' and 'from' Having read through the docs for both Email::Stuffer (Email::Sender) and Mail::Sendmail, I believe the meaning of 'from' and 'Sender' has reversed between the two modules. Email::Sendmail interpreted 'from' as the from address of the mail and used Sender as an override for the envelope when it was passed. However, in Email::Stuffer the 'from' is set at the envelope level and thus sets the connection 'MAIL FROM' which is subsequently used as the return-path by the mail server. It then uses 'Sender' as the message from address if one is passed in as a header. This patch reverses our handling of those attribute in Koha::Email. --- Koha/Email.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Koha/Email.pm b/Koha/Email.pm index cac63763ab..2047bc4e6f 100644 --- a/Koha/Email.pm +++ b/Koha/Email.pm @@ -76,7 +76,11 @@ sub create { my ( $self, $params ) = @_; my $args = {}; - $args->{from} = $params->{from} || C4::Context->preference('KohaAdminEmailAddress'); + $args->{from} = + $params->{sender} + || C4::Context->preference('ReturnpathDefault') + || $params->{from} + || C4::Context->preference('KohaAdminEmailAddress'); Koha::Exceptions::BadParameter->throw( error => "Invalid 'from' parameter: " . $args->{from}, parameter => 'from' @@ -101,9 +105,8 @@ sub create { $addresses->{reply_to} ||= C4::Context->preference('ReplytoDefault') if C4::Context->preference('ReplytoDefault'); - $addresses->{sender} = $params->{sender}; - $addresses->{sender} ||= C4::Context->preference('ReturnpathDefault') - if C4::Context->preference('ReturnpathDefault'); + $addresses->{sender} = + $params->{from} || C4::Context->preference('KohaAdminEmailAddress'); unless ( C4::Context->preference('SendAllEmailsTo') ) { $addresses->{cc} = $params->{cc} -- 2.20.1