[Bug 32575] New: gather_print_notices.pl sends HTML file as body of email
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Bug ID: 32575 Summary: gather_print_notices.pl sends HTML file as body of email Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Notices Assignee: koha-bugs@lists.koha-community.org Reporter: magnus@libriotech.no QA Contact: testopia@bugs.koha-community.org gather_print_notices.pl can send print notices to the library, as an HTML file attached to an email. At least some libraries report that the HTML does not come as an attached file, but as the body of the email. This breaks printing the notices properly. I am not sure if this is a problem with the emails generated by gather_print_notices.pl or with the email clients (or other software) used by the libraries that have this problem. A quick solution has been to add some body text to the emails generated by gather_print_notices.pl: 299 my $email = Koha::Email->create( 300 { 301 from => $from, 302 to => $to, 303 subject => 'Print notices for ' . $today_syspref, 304 text_body => 'See attached file.', # <==== Added this 305 } 306 ); This seems to force the attachment to be seen as an attachment, and not as the body of the email. In the headers of the emails sent by the standard gather_print_notices.pl I have seen this: Content-Transfer-Encoding: base64 Content-Type: text/html; charset=iso-8859-1 PCFET0NU... [lots of base64] When I have added some body text it looks more like this: Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="16633311691.0Ab5.3555417" --16633311691.0Ab5.3555417 Date: Fri, 16 Sep 2022 14:26:09 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable See attached file. --16633311691.0Ab5.3555417 Date: Fri, 16 Sep 2022 14:26:09 +0200 MIME-Version: 1.0 Content-Type: text/html; name="notices_all-2022-09-16-KOHA.html" Content-Disposition: attachment; filename="notices_all-2022-09-16-KOHA.html" Content-Transfer-Encoding: base64 PCFET0... [lots of base64] So unless something is changed on the way from Koha to the mail client, it looks like gather_print_notices.pl sends the HTML from the document as the body of the email. Not sure if this is a problem in Koha::Email->create that should be fixed there, or if it makes sense to just add some default text to the email, to fix the problem in the least obtrusive way? -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au Summary|gather_print_notices.pl |gather_print_notices.pl |sends HTML file as body of |sends attachment as body of |email |email or poorly named txt | |file -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |dcook@prosentient.com.au |ity.org | --- Comment #1 from David Cook <dcook@prosentient.com.au> --- Most of my clients don't use this script, but I have bumped into this issue with those that do. I'm also able to reproduce it using koha-testing-docker, a quick Perl script, and an external SMTP server. -- If you look at Email::Stuffer::email() and Email::MIME::parts_set(), it becomes clear that if Email::Stuffer only has 1 part (e.g. an attachment), it will always be sent out as a single part email (ie direct attachment) and not a multipart. It seems that different email clients handle single part emails differently. As Magnus has observed, sometimes the HTML is in the body of an email. I see CSVs get added as attachments with the subject line of the email as the filename plus ".txt" at the end. I think the best practice is to use "multipart/mixed" even when there is only a single part as it has the best email client compatibility. But that's not how Email::MIME seems to work. -- In the past, I've solved this the same way Magnus has by adding a "text_body" value. Even if it's just " ", it would work. However, it appears that an alternative is just to set the "Content-Type" header at the email level. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #2 from David Cook <dcook@prosentient.com.au> --- Here's a little test program for using in koha-testing-docker: #!/usr/bin/perl use Modern::Perl; use C4::Context; use Koha::Email; use Koha::SMTP::Servers; my $transport = Koha::SMTP::Servers->get_default->transport; my $email = Koha::Email->create( { from => C4::Context->preference('KohaAdminEmailAddress'), to => 'your@email.address', subject => 'My test email', } ); $email->header('Content-Type' => 'multipart/mixed'); my $filepath = '/tmp/notices_ODUE3-2024-06-17.csv'; my $filename = 'notices_ODUE3-2024-06-17.csv'; my $mimetype = 'text/csv'; $email->attach_file( $filepath, content_type => $mimetype, charset => 'UTF-8', name => $filename, disposition => 'attachment', ); $email->send_or_die( { transport => $transport } ); -- Some steps: 1. Set up the SMTP server config in koha-conf.xml for a server that works 2. Set up a valid email sender in KohaAdminEmailAddress 3. Create a little CSV file at /tmp/notices_ODUE3-2024-06-17.csv 4. Run the program -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #3 from David Cook <dcook@prosentient.com.au> --- One disadvantage of explicitly setting the Content-Type at the email level in lieu of a text body (empty or otherwise) is that it appears SMTP injected footers don't get added. So I'm actually inclined to go with an empty text body, so that SMTP servers can still add their footers. I'm hesitant to put in a text body of "See attached file" just because it would be hard-coded to English, and I think creating a whole notice template for gather_print_notices.pl is a bit overkill at this point. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #4 from David Cook <dcook@prosentient.com.au> --- Created attachment 167779 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=167779&action=edit Bug 32575: Tidy patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #5 from David Cook <dcook@prosentient.com.au> --- Created attachment 167780 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=167780&action=edit Bug 32575: Add an empty text body to fix multipart/mixed handling By adding an empty text body, we force Email::Stuffer/Email::MIME to use multipart/mixed handling for the attachment instead of forcing a single part (ie direct attachment) email, which is not consistently handled by different email clients. An empty text body is language-neutral (ie not imposing English), and it allows SMTP servers to inject organisational footers into the email (e.g. confidentiality notices). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #167779|0 |1 is obsolete| | --- Comment #6 from David Cook <dcook@prosentient.com.au> --- Created attachment 167781 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=167781&action=edit Bug 32575: Tidy patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #7 from David Cook <dcook@prosentient.com.au> --- This is a tough one to test on koha-testing-docker, as you need an available SMTP server. To test the script itself, you'd need to generate notices as well. It's a pretty simple change overall, and the program I added in the comments earlier can prove the concept for anyone who has a SMTP server available for their ktd... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #8 from David Cook <dcook@prosentient.com.au> --- Of course, I notice that the subject is hard coded to English with: "Print notices for " . $today_syspref. Maybe it's not a drama to have the body text in English? Or have some default text that is overridden using a CLI option? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #9 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Could we maybe clarify the description of the bug a bit? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #10 from David Cook <dcook@prosentient.com.au> --- (In reply to Katrin Fischer from comment #9)
Could we maybe clarify the description of the bug a bit?
When no text/html body is added to the email (which is always with this email), attachments aren't attached correctly. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Magnus Enger <magnus@libriotech.no> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Magnus Enger <magnus@libriotech.no> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #167780|0 |1 is obsolete| | --- Comment #11 from Magnus Enger <magnus@libriotech.no> --- Created attachment 167820 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=167820&action=edit Bug 32575: Add an empty text body to fix multipart/mixed handling By adding an empty text body, we force Email::Stuffer/Email::MIME to use multipart/mixed handling for the attachment instead of forcing a single part (ie direct attachment) email, which is not consistently handled by different email clients. An empty text body is language-neutral (ie not imposing English), and it allows SMTP servers to inject organisational footers into the email (e.g. confidentiality notices). Signed-off-by: Magnus Enger <magnus@libriotech.no> I have tested this solution in production, and it works for me. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Magnus Enger <magnus@libriotech.no> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #167781|0 |1 is obsolete| | --- Comment #12 from Magnus Enger <magnus@libriotech.no> --- Created attachment 167821 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=167821&action=edit Bug 32575: Tidy patch Signed-off-by: Magnus Enger <magnus@libriotech.no> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #167820|0 |1 is obsolete| | --- Comment #13 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 168225 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=168225&action=edit Bug 32575: Add an empty text body to fix multipart/mixed handling By adding an empty text body, we force Email::Stuffer/Email::MIME to use multipart/mixed handling for the attachment instead of forcing a single part (ie direct attachment) email, which is not consistently handled by different email clients. An empty text body is language-neutral (ie not imposing English), and it allows SMTP servers to inject organisational footers into the email (e.g. confidentiality notices). Signed-off-by: Magnus Enger <magnus@libriotech.no> I have tested this solution in production, and it works for me. Bug 32575: Tidy patch Signed-off-by: Magnus Enger <magnus@libriotech.no> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |m.de.rooy@rijksmuseum.nl |y.org | CC| |m.de.rooy@rijksmuseum.nl -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Patch doesn't apply --- Comment #14 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Hm, bit odd since the patches were just re-attached this morning: Apply? [(y)es, (n)o, (i)nteractive] y Applying: Bug 32575: Tidy patch error: sha1 information is lacking or useless (misc/cronjobs/gather_print_notices.pl). error: could not build fake ancestor Patch failed at 0001 Bug 32575: Tidy patch hint: Use 'git am --show-current-patch=diff' to see the failed patch When you have resolved this problem run "git bz apply --continue". If you would prefer to skip this patch, instead run "git bz apply --skip". To restore the original branch and stop patching run "git bz apply --abort". Patch left in /tmp/Bug-32575-Tidy-patch-ghgaof9i.patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #15 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Ah, wrong sequence. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #167821|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #16 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Looks like the Tidy patch was squashed with the other patch in this case. Obsoleted the tidy patch, QA tools pass, patch applies that way. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #17 from David Cook <dcook@prosentient.com.au> --- (In reply to Katrin Fischer from comment #16)
Looks like the Tidy patch was squashed with the other patch in this case. Obsoleted the tidy patch, QA tools pass, patch applies that way.
I noticed the status is "Patch doesn't apply". Is that still the case or should it be changed? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Patch doesn't apply |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 --- Comment #18 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- No, it's actually pushed, but the script didn't pick it up for the wrong status. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to main Version(s)| |24.11 released in| | --- Comment #19 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Pushed to main for 24.11, thanks all! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|24.11 |24.11.00 released in| | CC| |david@davidnind.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com Status|Pushed to main |Pushed to stable Version(s)|24.11.00 |24.11.00,24.05.06 released in| | --- Comment #20 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Backported to 24.05.x for upcoming 24.05.06 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|24.11.00,24.05.06 |24.11.00,24.05.06,23.11.11 released in| | Status|Pushed to stable |Pushed to oldstable CC| |fridolin.somers@biblibre.co | |m --- Comment #21 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to 23.11.x for 23.11.11 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the| |This fixes emails generated release notes| |by the | |misc/cronjobs/gather_print_ | |notices.pl script. It adds | |empty text to the body of | |the email, so that the HTML | |file with the print notices | |is correctly attached to | |the email, and can be | |correctly printed. Because | |of the way the notices were | |being sent, and the way | |that different email | |clients handle different | |types of attachments, the | |notices were sometimes | |inserted into the body of | |the email or attached as | |poorly named text files. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32575 Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to oldstable |Needs documenting CC| |wainuiwitikapark@catalyst.n | |et.nz --- Comment #22 from Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz> --- Not backporting to 22.11 unless requested -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org