Bug 27884

Summary: Add HTML mail support for patron emailer script
Product: Koha Reporter: David Gustafsson <glasklas>
Component: ReportsAssignee: David Gustafsson <glasklas>
Status: RESOLVED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: trivial    
Priority: P5 - low CC: amitddng135, black23, fridolin.somers, joonas.kylmala, kyle, martin.renvoize, sally.healey, victor
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Text to go in the release notes:
Version(s) released in:
21.11.00,21.05.05,20.11.12
Attachments: Bug 123123: Add html support for report mails
Bug 123123: Add html support for report mails
Bug 123123: Add html support for report mails
Bug 123123: Add html support for report mails
Bug 27884: Add html support for report mails
Bug 27884: Add tests
Bug 27884: Add html support for report mails
Bug 27884: Add tests
Bug 27884: Add html support for report mails
Bug 27884: Add tests

Description David Gustafsson 2021-03-05 15:46:15 UTC
In bug 16149 patron_emailer.pl was added so reports can send mail to users. This mail is administered in the same way as other notice-templates (tools, notices and slips). When creating mail templates there is an option for plaintext or html mail. This setting is not respected for emails handled by patron_emailer.pl which this patch should fix.
Comment 1 David Gustafsson 2021-03-05 15:48:45 UTC
Created attachment 117869 [details] [review]
Bug 123123: Add html support for report mails
Comment 2 Michal Denar 2021-03-07 20:36:58 UTC
Hi David,any test plan?

Thank you.
Comment 3 David Gustafsson 2021-03-08 17:59:15 UTC Comment hidden (obsolete)
Comment 4 David Gustafsson 2021-03-08 18:00:43 UTC
Created attachment 117943 [details] [review]
Bug 123123: Add html support for report mails

To test:
1) Create a new notice, for example with Koha module "Patrons",
   name/code TEST and message body "<strong>testing<strong>".
2) Create a new sql report, the query could be someting like:
   SELECT "<number>" as `borrowernumber`, "to@example.com", as `email`, "from@example.com" as `from`;
   where "<number>" is a valid borrowernumber.
3) Run patron_emailer.pl --report=<id> --notice=TEST --module=members -commit
   where <id> is the report id.
4) Check the message_queue table that the content_type column has been
   set to text/html; charset="UTF-8".
5) Ideally process the message queue and veriy that the sent email is displayed
   as rendered html.
Comment 5 Amit Gupta 2021-03-29 04:17:08 UTC
Created attachment 118929 [details] [review]
Bug 123123: Add html support for report mails

To test:
1) Create a new notice, for example with Koha module "Patrons",
   name/code TEST and message body "<strong>testing<strong>".
2) Create a new sql report, the query could be someting like:
   SELECT "<number>" as `borrowernumber`, "to@example.com", as `email`, "from@example.com" as `from`;
   where "<number>" is a valid borrowernumber.
3) Run patron_emailer.pl --report=<id> --notice=TEST --module=members -commit
   where <id> is the report id.
4) Check the message_queue table that the content_type column has been
   set to text/html; charset="UTF-8".
5) Ideally process the message queue and veriy that the sent email is displayed
   as rendered html.
Comment 6 Joonas Kylmälä 2021-04-01 09:02:56 UTC
Looks good but an automated test is still needed for this in t/db_dependent/Reports/Guided.t
Comment 7 Joonas Kylmälä 2021-04-01 09:05:06 UTC
The bug number was also not right in the patch title.
Comment 8 David Gustafsson 2021-09-15 13:33:08 UTC
Created attachment 124890 [details] [review]
Bug 27884: Add html support for report mails

To test:
1) Create a new notice, for example with Koha module "Patrons",
   name/code TEST and message body "<strong>testing<strong>".
2) Create a new sql report, the query could be someting like:
   SELECT "<number>" as `borrowernumber`, "to@example.com", as `email`, "from@example.com" as `from`;
   where "<number>" is a valid borrowernumber.
3) Run patron_emailer.pl --report=<id> --notice=TEST --module=members -commit
   where <id> is the report id.
4) Check the message_queue table that the content_type column has been
   set to text/html; charset="UTF-8".
5) Ideally process the message queue and veriy that the sent email is displayed
   as rendered html.
6) Run tests in t/db_dependent/Reports/Guided.t
Comment 9 David Gustafsson 2021-09-15 13:33:12 UTC
Created attachment 124891 [details] [review]
Bug 27884: Add tests
Comment 10 David Nind 2021-10-06 02:26:06 UTC
Created attachment 125755 [details] [review]
Bug 27884: Add html support for report mails

To test:
1) Create a new notice, for example with Koha module "Patrons",
   name/code TEST and message body "<strong>testing<strong>".
2) Create a new sql report, the query could be someting like:
   SELECT "<number>" as `borrowernumber`, "to@example.com", as `email`, "from@example.com" as `from`;
   where "<number>" is a valid borrowernumber.
3) Run patron_emailer.pl --report=<id> --notice=TEST --module=members -commit
   where <id> is the report id.
4) Check the message_queue table that the content_type column has been
   set to text/html; charset="UTF-8".
5) Ideally process the message queue and veriy that the sent email is displayed
   as rendered html.
6) Run tests in t/db_dependent/Reports/Guided.t

Signed-off-by: David Nind <david@davidnind.com>
Comment 11 David Nind 2021-10-06 02:26:11 UTC
Created attachment 125756 [details] [review]
Bug 27884: Add tests

Signed-off-by: David Nind <david@davidnind.com>
Comment 12 Martin Renvoize 2021-11-01 17:19:39 UTC
Created attachment 127184 [details] [review]
Bug 27884: Add html support for report mails

To test:
1) Create a new notice, for example with Koha module "Patrons",
   name/code TEST and message body "<strong>testing<strong>".
2) Create a new sql report, the query could be someting like:
   SELECT "<number>" as `borrowernumber`, "to@example.com", as `email`, "from@example.com" as `from`;
   where "<number>" is a valid borrowernumber.
3) Run patron_emailer.pl --report=<id> --notice=TEST --module=members -commit
   where <id> is the report id.
4) Check the message_queue table that the content_type column has been
   set to text/html; charset="UTF-8".
5) Ideally process the message queue and veriy that the sent email is displayed
   as rendered html.
6) Run tests in t/db_dependent/Reports/Guided.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 13 Martin Renvoize 2021-11-01 17:19:43 UTC
Created attachment 127185 [details] [review]
Bug 27884: Add tests

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 14 Martin Renvoize 2021-11-01 17:20:15 UTC
Trivial fix covered by tests.. works well..

Passing QA
Comment 15 Jonathan Druart 2021-11-02 15:53:02 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 16 Kyle M Hall 2021-11-05 15:55:12 UTC
Pushed to 21.05.x for 21.05.05
Comment 17 Fridolin Somers 2021-11-11 01:38:41 UTC
Pushed to 20.11.x for 20.11.12
Comment 18 Victor Grousset/tuxayo 2021-11-16 07:40:43 UTC
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.