Generating email notices

Note: the following method is the legacy way of generating email notices for overdues and reminders. A new method based on the action/trigger/event mechanism launched in Evergreen 1.6 relying on passive scripts and supports wonderful things like patron's locale preferences, etc. However, the legacy method is what we have working today, so let's roll with it.

Out of the box, Evergreen provides templates for a reminder notice the day before an item is due, and an overdue notice that is generated 7 days after the item was due.


The script should be run as the opensrf user to ensure that it has access to the required configuration files and environment variables.

We have to run the script out of the pertinent Evergreen source directory due to a dependency on Eventually we should probably just copy all the files into the normal /openils/bin directory, but for now we start everything with:

cd /home/lauadmin/Evergreen-trunk/Open-ILS/src/support-scripts/


We can dump the help for the script using the following command:

perl --help

This returns:

Evergreen Circulation Notice Generator

    ---osrf_config <config_file>

        If set, generate email notices

    --use-email-outfile <file>
        Instead of sending emails, append each email (complete with headers) to this file

    --use-email-recipient <>
        Send all email notices to this user instead of the patron.  This updates the
        email address on the user object attached to the circulations, so no
        change to the email templates is required.

        If set, notices which have a notify_interval of >= 1 day will be processed.

        Collect all non-emailed notices into a global set and generate templates based on that set.

        If an attempt was made to send an email notice but it failed, the notice is appended
        to the global notice file set.  This will only have any bearing if --generate-global-templates
        is enabled.

    --days-back <days_back_comma_separted>
        This is used to set the effective run date of the script.
        This is useful if you don't want to generate notices on certain days.  For example, if you don't
        generate notices on the weekend, you would run this script on weekdays and set --days-back to
        0,1,2 when it's run on Monday to capture any notices from Saturday and Sunday.

    --notice-types <overdue,predue,...>
        Comma-separated list of notice types to generate for this run of the script

        Print this help message


So, to dump the output of both reminders and overdues into a file for review for the last 7 days:

perl --use-email-outfile ~/fakeemail.lst --notice-type overdue,predue --days-back 0,1,2,3,4,5,6,7

Note that it doesn't really make sense to dump the reminders for the last 7 days, because the previous days will be warning people about items being overdue tomorrow, when in fact they might be as much as 6 days overdue by that time. But it does give you an idea of what would have been sent.

Cron job

Putting all of this together, a cron job is scheduled under the opensrf user on - with one additional wrinkle. Because cron environments aren't run in the user's login shell, we have to set certain environment variables manually. In this case, we need to set PERL5LIB. So, to schedule the overdue and reminder notices to run at 06:01 every day:

01 06 * * * cd /home/lauadmin/Evergreen-trunk/Open-ILS/src/support-scripts/; PERL5LIB=/openils/lib/perl5 perl --send-email --notice-type overdue,predue }}}
Last modified 14 years ago Last modified on Jun 24, 2009, 12:20:40 AM