From e650e29935c9d90cd74ef1b5c43fef0bf457b530 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 17 Jun 2021 14:12:23 +0100 Subject: [PATCH] Bug 28581: (QA follow-up) Prevent code failure Content-Type: text/plain; charset=utf-8 This patch prevents a fatal error when both $params->{from} and $params->{borrowernumber} are undefined. We fallback to KohaAdminEmailAddress before finally falling through to setting a failure status for the message if that last fallback is not found. Signed-off-by: Marcel de Rooy --- C4/Letters.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 713812c863..c442d06d7a 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1346,12 +1346,15 @@ sub _send_message_by_email { if ($patron) { $library = $patron->library; - $branch_email = $library->branchemail; + $branch_email = $library->from_email_address; $branch_replyto = $library->branchreplyto; $branch_returnpath = $library->branchreturnpath; } - my $from_address = $message->{'from_address'} || $library->from_email_address; + my $from_address = + $message->{'from_address'} + || $branch_email + || C4::Context->preference('KohaAdminEmailAddress'); if( !$from_address ) { _set_message_status({ message_id => $message->{'message_id'}, -- 2.20.1