Bug 36314 - koha-email-disable does not disable all emails
Summary: koha-email-disable does not disable all emails
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low major (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-14 07:55 UTC by Jonathan Druart
Modified: 2024-03-15 07:11 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2024-03-14 07:55:54 UTC
koha-email-enable and koha-email-disable are creating/removing a file (email.enabled) to know if a given instance can send emails.

However this is not used from everywhere in Koha, only some debian scripts.
Comment 1 Magnus Enger 2024-03-14 08:15:24 UTC
I can't claim to have a full overview of this, but here are some points that come to mind: 

koha-list has the --email and --noemail switches, to only list instances that have email enabled and disabled respectively. 

koha-foreach also has the --email and --noemail switches, which build on the functionality in koha-list. 

Some standard cronjobs that are set up when Koha is installed with the Debian packages use koha-foreach --email, including this: 

*/15 * * * * root koha-foreach --chdir --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl

So most messages should be stopped when email is disabled. Including SMS and print (which could come as a surprise, based on the name of the koha-email-{enable,disable} scripts). 

But there are some functions in Koha that sends email immediately, without relying on process_message_queue.pl. These include, but are not necessarily limited to: 

- Password reset
- Welcome email to newly registered patrons (not sure if that only includes self registered patrons in the OPAC?)

Not sure if these respect the email.enabled file.
Comment 2 Tomás Cohen Arazi 2024-03-14 12:33:09 UTC
`koha-email-{enabled|disable}` is only used by `koha-list`. I'm not sure what's the best approach to this. We could have a syspref instead of email.enabled.
Comment 3 Katrin Fischer 2024-03-14 21:48:10 UTC
I think we have used this during migrations and such. 

If we move to a system preference that could also work, but like the email switch it should not only stop sending out the emails, but also prevent their generation in the first place.
Comment 4 David Cook 2024-03-14 23:16:46 UTC
(In reply to Katrin Fischer from comment #3)
> I think we have used this during migrations and such. 
> 
> If we move to a system preference that could also work, but like the email
> switch it should not only stop sending out the emails, but also prevent
> their generation in the first place.

I'm not sure that I understand. If you have email disabled, emails will still be generated in Koha. That's something I like because sometimes I want to test email generation without risking sending out emails.
Comment 5 Katrin Fischer 2024-03-15 06:12:54 UTC
Hm, my impression always was that the cronjob would not run at all with the flag set. Maybe I am wrong and clearly we need to document the intended behavior.
Comment 6 Magnus Enger 2024-03-15 07:11:22 UTC
Yeah, when a cronjob is set up with "koha-foreach --email" it will not run if email is disabled. But I can understand David's wish to generate the emails without sending them out. So maybe two sysprefs? 

- One to not generate messages at all
- One to generate messages, bit not send them out

This way you could enable generating messages and disable sending them out, to test something, and then delete any unwanted messages before you enable sending messages out.