From 8f9b4109d199153194c66374a8aab3c50afa4597 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 25 Feb 2020 09:05:18 +0000 Subject: [PATCH] Bug 22821: Use 'reply-to' address in issue notes This patch updates the issue notices to not pass from_address and so default to the branch email of the user for from_address. We now pass the patrons email (cascading through email, emailpro, B_email) into the reply_address field so mail servers are less likely to report emails as spam and mail clients still have access to the patron address via the reply-to header when staff want to hit 'reply' and have the email go to the user. Signed-off-by: Myka Kennedy Stephens --- C4/Letters.pm | 11 ++++++----- opac/opac-issue-note.pl | 4 ++-- opac/svc/checkout_notes | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 0233ef52f4..7c5d470bb0 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -912,9 +912,9 @@ sub EnqueueLetter { my $dbh = C4::Context->dbh(); my $statement = << 'ENDSQL'; INSERT INTO message_queue -( borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, content_type ) +( borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, reply_address, content_type ) VALUES -( ?, ?, ?, ?, ?, ?, ?, NOW(), ?, ?, ? ) +( ?, ?, ?, ?, ?, ?, ?, NOW(), ?, ?, ?, ? ) ENDSQL my $sth = $dbh->prepare($statement); @@ -928,6 +928,7 @@ ENDSQL 'pending', # status $params->{'to_address'}, # to_address $params->{'from_address'}, # from_address + $params->{'reply_address'}, # reply_address $params->{'letter'}->{'content-type'}, # content_type ); return $dbh->last_insert_id(undef,undef,'message_queue', undef); @@ -1124,7 +1125,7 @@ sub GetMessage { return unless $message_id; my $dbh = C4::Context->dbh; return $dbh->selectrow_hashref(q| - SELECT message_id, borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, updated_on, to_address, from_address, content_type + SELECT message_id, borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, updated_on, to_address, from_address, reply_address, content_type FROM message_queue WHERE message_id = ? |, {}, $message_id ); @@ -1228,7 +1229,7 @@ sub _get_unsent_messages { my $dbh = C4::Context->dbh(); my $statement = qq{ - SELECT mq.message_id, mq.borrowernumber, mq.subject, mq.content, mq.message_transport_type, mq.status, mq.time_queued, mq.from_address, mq.to_address, mq.content_type, b.branchcode, mq.letter_code + SELECT mq.message_id, mq.borrowernumber, mq.subject, mq.content, mq.message_transport_type, mq.status, mq.time_queued, mq.from_address, mq.reply_address, mq.to_address, mq.content_type, b.branchcode, mq.letter_code FROM message_queue mq LEFT JOIN borrowers b ON b.borrowernumber = mq.borrowernumber WHERE status = ? @@ -1314,7 +1315,7 @@ sub _send_message_by_email { : () ), from => $message->{'from_address'} || $branch_email, - replyto => $branch_replyto, + replyto => $message->{'reply_address'} || $branch_replyto, sender => $branch_returnpath, subject => $subject, message => $is_html ? _wrap_html( $content, $subject ) : $content, diff --git a/opac/opac-issue-note.pl b/opac/opac-issue-note.pl index f61b33cd8f..64f07fefbd 100755 --- a/opac/opac-issue-note.pl +++ b/opac/opac-issue-note.pl @@ -82,14 +82,14 @@ if ( $action eq 'issuenote' && C4::Context->preference('AllowCheckoutNotes') ) { ); my $to_address = $branch->branchemail || $branch->branchreplyto || C4::Context->ReplytoDefault || C4::Context->preference('KohaAdminEmailAddress'); - my $from_address = $patron->email || $patron->emailpro || $patron->B_email; + my $reply_address = $patron->email || $patron->emailpro || $patron->B_email; C4::Letters::EnqueueLetter({ letter => $letter, message_transport_type => 'email', borrowernumber => $patron->borrowernumber, to_address => $to_address, - from_address => $from_address, + reply_address => $reply_address, }); } } diff --git a/opac/svc/checkout_notes b/opac/svc/checkout_notes index a5682c8ceb..60b4d00bca 100755 --- a/opac/svc/checkout_notes +++ b/opac/svc/checkout_notes @@ -92,14 +92,14 @@ if ($is_ajax) { ); my $to_address = $branch->branchemail || $branch->branchreplyto || C4::Context->preference('ReplytoDefault') || C4::Context->preference('KohaAdminEmailAddress'); - my $from_address = $patron->email || $patron->emailpro || $patron->B_email; + my $reply_address = $patron->email || $patron->emailpro || $patron->B_email; C4::Letters::EnqueueLetter({ letter => $letter, message_transport_type => 'email', borrowernumber => $patron->borrowernumber, to_address => $to_address, - from_address => $from_address, + reply_address => $reply_address, }); } else { # note empty, i.e removed $status = "removed"; -- 2.11.0