Commit 28041692 authored by Kyle M Hall's avatar Kyle M Hall Committed by Galen Charlton

Bug 5544: prefer library email address over admin address as notice sender

Right now overdues come from the branch, but the
others come from the admin email address - this
is a problem in multi-branch systems because they
have to come up with one email address that all
branches have access to.

C4::Letters::_send_message_by_email currently sets
the from address in the following order:
1) Address specified in message
2) Koha admin email address

The order will now be:
1) Address specified in message
2) Borrower's home library email address
3) Koha admin email address

Test Plan:
1) Set your library email addresses, and the KohaAdminEmailAddress
   Make sure each of them are unqiue
2) Choose a borrower, enable the enhanced messaging and enable the
   checkout and checkin email notices. Use your email address for
   the borrower's email so you can recieve the emails.
3) Check out an item, check the from address of the email,
   it should be the email addres set in KohaAdminEmailAddress
4) Apply the patch
5) Return the item, check the from address of the email,
   it should match the email address set for the borrower's
   home library.
Signed-off-by: default avatarChris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: default avatarMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton's avatarGalen Charlton <gmc@esilibrary.com>
parent 117f8a5c
...@@ -920,9 +920,9 @@ sub _send_message_by_email { ...@@ -920,9 +920,9 @@ sub _send_message_by_email {
my $message = shift or return; my $message = shift or return;
my ($username, $password, $method) = @_; my ($username, $password, $method) = @_;
my $to_address = $message->{to_address}; my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
my $to_address = $message->{'to_address'};
unless ($to_address) { unless ($to_address) {
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
unless ($member) { unless ($member) {
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
_set_message_status( { message_id => $message->{'message_id'}, _set_message_status( { message_id => $message->{'message_id'},
...@@ -947,7 +947,7 @@ sub _send_message_by_email { ...@@ -947,7 +947,7 @@ sub _send_message_by_email {
my $is_html = $content_type =~ m/html/io; my $is_html = $content_type =~ m/html/io;
my %sendmail_params = ( my %sendmail_params = (
To => $to_address, To => $to_address,
From => $message->{'from_address'} || C4::Context->preference('KohaAdminEmailAddress'), From => $message->{'from_address'} || GetBranchDetail( $member->{'branchcode'} )->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'),
Subject => $subject, Subject => $subject,
charset => 'utf8', charset => 'utf8',
Message => $is_html ? _wrap_html($content, $subject) : $content, Message => $is_html ? _wrap_html($content, $subject) : $content,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment