Bug 31627: Add ability to embed the letter id in outgoing email notices

It can be useful to know exactly what template was used to generate a notice. To further this end, it would be useful be able to send the letter id as part of any emails sent out if there is a letter template associated with the message.

Test Plan:
1) Apply this patch
2) Restart all the things!
3) Generate an email notice like a checkout notice
4) Inspect the email headers, note the new X-Koha-Template-Id and
   X-Koha-Message-Id headers!

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Kyle Hall 2022-09-26 12:23:33 -04:00 committed by Katrin Fischer
parent 6e09fb6ad8
commit aed4a2ec98
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -1293,7 +1293,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.reply_address, mq.to_address, mq.content_type, b.branchcode, mq.letter_code, mq.failure_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, mq.failure_code, mq.letter_id
FROM message_queue mq
LEFT JOIN borrowers b ON b.borrowernumber = mq.borrowernumber
WHERE status = ?
@ -1464,6 +1464,8 @@ sub _send_message_by_email {
$email->create($params);
} else {
$email = Koha::Email->create($params);
$email->header('X-Koha-Letter-Id', $message->{letter_id} );
$email->header('X-Koha-Message-Id', $message->{id} );
if ($is_html) {
$email->html_body( _wrap_html( $content, $subject ) );
} else {