@@ -, +, @@ Koha::Patron --- Koha/Library.pm | 23 +++++++++++++++++++++++ Koha/Patron.pm | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) --- a/Koha/Library.pm +++ a/Koha/Library.pm @@ -143,12 +143,35 @@ sub smtp_server { return $self; } +=head3 from_email_address + + my $from_email = Koha::Library->from_email_address; + +Returns the official 'from' email address for the branch. + +It may well be a 'noreply' or other inaccessible local domain +address that is being used to satisfy spam protection filters. + +=cut + +sub from_email_address { + my ($self) = @_; + + return + || $self->branchemail + || C4::Context->preference('KohaAdminEmailAddress') + || undef; +} + =head3 inbound_email_address my $to_email = Koha::Library->inbound_email_address; Returns an effective email address which should be accessible to librarians at the branch. +NOTE: This is the address to use for 'reply_to' or 'to' fields; It should not usually be +used as the 'from' address for emails as it may lead to mail being caught by spam filters. + =cut sub inbound_email_address { --- a/Koha/Patron.pm +++ a/Koha/Patron.pm @@ -1874,7 +1874,7 @@ sub queue_notice { return unless exists $params->{message_name} xor $params->{message_transports}; # We only want one of these my $library = Koha::Libraries->find( $letter_params->{branchcode} ); - my $admin_email_address = $library->inbound_email_address; + my $from_email_address = $library->from_email_address; my @message_transports; my $letter_code; @@ -1909,7 +1909,7 @@ sub queue_notice { C4::Letters::EnqueueLetter({ letter => $letter, borrowernumber => $self->borrowernumber, - from_address => $admin_email_address, + from_address => $from_email_address, message_transport_type => $mtt }) unless $test_mode; push @{$return{sent}}, $mtt; --