From bcb14e869ebd1cde512c0bebeda0df2594a2fa65 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 17 Jun 2021 09:18:47 +0000 Subject: [PATCH] Bug 28581: Do not send mail without a from address Content-Type: text/plain; charset=utf-8 Test plan: Make branch mail empty and KohaAdminEmailAddress. Trigger a message that goes thru the message queue. Check the log for a warning. Signed-off-by: Marcel de Rooy --- C4/Letters.pm | 5 +++++ Koha/Patron.pm | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/C4/Letters.pm b/C4/Letters.pm index d2a3f1265b..b38bdeaa46 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -925,6 +925,11 @@ sub EnqueueLetter { # return unless exists $params->{'borrowernumber'}; return unless exists $params->{'message_transport_type'}; + if( !$params->{from_address} ) { + warn 'EnqueueLetter: Sending a message without from_address not allowed.'; + return; # no exception: context contains various silent returns + } + my $content = $params->{letter}->{content}; $content =~ s/\s+//g if(defined $content); if ( not defined $content or $content eq '' ) { diff --git a/Koha/Patron.pm b/Koha/Patron.pm index a8379f6228..4c5960083e 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1875,6 +1875,11 @@ sub queue_notice { my $library = Koha::Libraries->find( $letter_params->{branchcode} ); my $from_email_address = $library->from_email_address; + if( !$from_email_address ) { + # No exception since we 'silently' return here for various reasons.. + warn 'queue_notice: Found no branch email address; KohaAdminEmailAddress is empty too.'; + return; + } my @message_transports; my $letter_code; -- 2.20.1