advance_notices.pl - cron script to put item due reminders into message queue


./advance_notices.pl -c

or, in crontab: 0 1 * * * advance_notices.pl -c


This script prepares pre-due and item due reminders to be sent to patrons. It queues them in the message queue, which is processed by the process_message_queue.pl cronjob. The type and timing of the messages can be configured by the patrons in their "My Alerts" tab in the OPAC.


advance_notices.pl - prepare messages to be sent to patrons for nearly due, or due, items


advance_notices.pl [ -n ][ -m <number of days> ][ --itemscontent <comma separated field list> ][ -c ]



Print a brief help message and exits.


Prints the manual page and exits.


Verbose. Without this flag set, only fatal errors are reported.


Do not send any email. Advanced or due notices that would have been sent to the patrons are printed to standard out.


Defines the maximum number of days in advance to send advance notices.


Confirm flag: Add this option. The script will only print a usage statement otherwise.


comma separated list of fields that get substituted into templates in places of the <<items.content>> placeholder. This defaults to date_due,title,author,barcode

Other possible values come from fields in the biblios, items and issues tables.


Flag to indicate that generation of message digests should be performed separately for each branch.

A patron could potentially have loans at several different branches There is no natural branch to set as the sender on the aggregated message in this situation so the default behavior is to use the borrowers home branch. This could surprise to the borrower when message sender is a library where they have not borrowed anything.

Enabling this flag ensures that the issuing library is the sender of the digested message. It has no effect unless the borrower has chosen 'Digests only' on the advance messages.


This script is designed to alert patrons when items are due, or coming due


This script pays attention to the advanced notice configuration performed by borrowers in the OPAC, or by staff in the patron detail page of the intranet. The content of the messages is configured in Tools -> Notices and slips. Advanced notices use the PREDUE template, due notices use DUE. More information about the use of this section of Koha is available in the Koha manual.

Outgoing emails

Typically, messages are prepared for each patron with due items, and who have selected (or the library has elected for them) Advance or Due notices.

These emails are staged in the outgoing message queue, as are messages produced by other features of Koha. This message queue must be processed regularly by the misc/cronjobs/process_message_queue.pl program.

In the event that the -n flag is passed to this program, no emails are sent. Instead, messages are sent on standard output from this program. They may be redirected to a file if desired.


Templates can contain variables enclosed in double angle brackets like <<this>>. Those variables will be replaced with values specific to the overdue items or relevant patron. Available variables are:


one line for each item, each line containing a tab separated list of date due, title, author, barcode


any field from the borrowers table


any field from the branches table


The misc/cronjobs/overdue_notices.pl program allows you to send messages to patrons when their messages are overdue.





        digests => ...,
        sth => ...,
        letter_code => ...,
        get_item_info => ...,

Enqueue digested letters (or print them if -n was passed at command line).



Reference to the array of digested messages.


Prepared statement handle for fetching overdue issues.


String that denote the letter code.


Subroutine for executing prepared statement. Takes parameters $sth, $borrowernumber and $borrower_parameters and return a generator function that produce the matching rows.