From db5e44fa1ba1ad82d84289210e65430ec5b997f1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 8 Nov 2023 16:41:02 +0000 Subject: [PATCH] Bug 18397: Add message delivery details to the notices tab This patch adds further delivery details to the notices tab in patron details in the staff client. Once a message is sent, we display the 'from:', 'to:' and 'cc:' addresses in the 'Delivery note' column when they exist. Test plan 1. Enable KTD to send email [1] (without email configured the delivery note displayed "Unhandled email failure, check the logs for further details"). 2. Add email addresses to two patrons and to KohaAdminEmailAddress, and run misc/cronjobs/process_message_queue.pl after generating notices. 3. For the two patrons with email addresses, make one a guarantor. 4. Sent Welcome messages (Patron account > More > Send welcome email) - nothing in delivery note column. 5. Checkout out an item to the guarantee (item checkout email enabled) - nothing in delivery note column. 6. Send the notices by running misc/cronjobs/process_message_queue.pl again. 7. Now the 'Delivery note' columns should contain from:, to: and cc: address details. [1] Option 1 - smpt-sink (aka the sandboxes way) - Install the postfix package inside ktd (sudo apt install postfix) When asked in the wizard, I named mine 'local' - Start smpt-sink with `nohup smtp-sink -u root -D mail 127.0.0.1:25 100 /dev/null 2>&1 &` Option 2 - To test sending emails using a Google account: - Set up an App password for your Google Account - Edit /etc/koha/sites/kohadev/koha-conf.xml file and add this configuration near the end (where = your Google email address; = your APP password, not your Google account password): smtp.gmail.com 587 5 STARTTLS GOOGLEACCOUNTUSER GOOGLEAPPPASSWORD 1 Signed-off-by: David Nind Signed-off-by: Aleisha Amohia Signed-off-by: Katrin Fischer (cherry picked from commit 137376ab4b624ae01d20e2106196c46a39dd8581) Signed-off-by: Fridolin Somers --- C4/Letters.pm | 2 +- .../prog/en/modules/members/notices.tt | 32 ++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 47e1252648..a0404ac707 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1116,7 +1116,7 @@ sub GetQueuedMessages { my $dbh = C4::Context->dbh(); my $statement = << 'ENDSQL'; -SELECT message_id, borrowernumber, subject, content, message_transport_type, status, time_queued, updated_on, failure_code +SELECT message_id, borrowernumber, subject, content, message_transport_type, status, time_queued, updated_on, failure_code, from_address, to_address, cc_address FROM message_queue ENDSQL diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt index 667b59a485..601c1b8b82 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt @@ -99,20 +99,28 @@ [% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %] [% IF ( QUEUED_MESSAGE.failure_code ) %] - [% IF ( QUEUED_MESSAGE.failure_code == "INVALID_BORNUMBER" ) %]Invalid borrowernumber [% borrowernumber | html %] - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_EMAIL' ) %]Unable to find an email address for this borrower - [% ELSIF (matches = QUEUED_MESSAGE.failure_code.match('INVALID_EMAIL:(\w+)') ) %]Invalid [% matches.0 | html %] email address found [% borrowernumber | html %] - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_FROM' ) %]Missing from email address - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'MISSING_SMS' ) %]Missing SMS number - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'DUPLICATE_MESSAGE' ) %]Message is duplicate - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_NOTES' ) %]No notes from SMS driver - [% ELSIF ( QUEUED_MESSAGE.failure_code == 'SENDMAIL' ) %]Unhandled email failure, check the logs for further details - [% ELSIF ( QUEUED_MESSAGE.failure_code == "UNKNOWN_ERROR" ) %]Unknown error - [% ELSE %]Error occurred while sending email. + [% IF ( QUEUED_MESSAGE.failure_code == "INVALID_BORNUMBER" ) %]Invalid borrowernumber [% borrowernumber | html %] + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_EMAIL' ) %]Unable to find an email address for this borrower + [% ELSIF (matches = QUEUED_MESSAGE.failure_code.match('INVALID_EMAIL:(\w+)') ) %]Invalid [% matches.0 | html %] email address found [% borrowernumber | html %] + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_FROM' ) %]Missing from email address + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'MISSING_SMS' ) %]Missing SMS number + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'DUPLICATE_MESSAGE' ) %]Message is duplicate + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_NOTES' ) %]No notes from SMS driver + [% ELSIF ( QUEUED_MESSAGE.failure_code == 'SENDMAIL' ) %]Unhandled email failure, check the logs for further details + [% ELSIF ( QUEUED_MESSAGE.failure_code == "UNKNOWN_ERROR" ) %]Unknown error + [% ELSE %]Error occurred while sending email. [% END %] [% END %] - [% IF ( QUEUED_MESSAGE.cc_address ) %] - Notice copied to: [% QUEUED_MESSAGE.cc_address | html %] + [% IF ( QUEUED_MESSAGE.status == 'sent' ) %] + [% IF ( QUEUED_MESSAGE.from_address ) %] + from: [% QUEUED_MESSAGE.from_address | html %] + [% END %] + [% IF ( QUEUED_MESSAGE.to_address ) %] + to: [% QUEUED_MESSAGE.to_address | html %] + [% END %] + [% IF ( QUEUED_MESSAGE.cc_address ) %] + cc: [% QUEUED_MESSAGE.cc_address | html %] + [% END %] [% END %]