Press enter after choosing selection

Library Card Renewal Alerts: a sonnet

by glenmodell

A tragedy! Your AADL card
Has now expired, and you must renew.
Just keeping track of all this stuff is hard,
And each new thing is one more thing to do.

But now, we send alerts out in advance,
One month before, by e-mail, as you'll see;
While III's Createlist does its dance,
The work is mostly done in PHP.

So now, you need remember one thing less,
Which hopefully will ease life's angst; and so,
If you decide this service (as we guess)
Is helpful, please feel free to let us know.

For those who travel Innovative's road:
The Clearinghouse is where I've put the code.

*****************************************

(P.S. If you are not with Triple-I,
You cannot use the Clearinghouse, you know;
And therefore, should you find you'd like to try
These card alerts, I've placed the code below.)

This is a PHP script, using the PEAR mail utility, which will notify a specified group of patrons by e-mail that their library cards are about to expire. It also lets them know when the expiration dates are.

First, use Createlist (or another data report writer, if you are not using the Innovative automation system) to make your list of patrons whom you would like to e-mail. Qualify the list by (1) the existence of an e-mail address, and (2) a range of expiration dates. Export this file as: e-mail address, pipe delimiter, expiration date. For example, a typical record would look like this:

modellg@aadl.org|03-15-2007

This data file is renewcards.txt. The PHP script works off this data file.

Here is the script:

#!/usr/bin/php5 -q
<?php

// This routine uses PEAR mail.
// It sends e-mail messages to patrons to renew cards.
// It works off a file whose records have this format:
// modellg@aadl.org|03-15-2007

// This is a required line. It refers to your PHP file location.

require_once ('/usr/share/php/Mail.php');

// You have previously exported the file 'renewcards.txt'.
// This reads the file into a string and removes ending whitespace.

$filestring = file_get_contents ('renewcards.txt');
$trimstring = trim ($filestring);

// This divides the string into records at each "\n".

$linearray = explode ("\n", $trimstring);

// These are PEAR mail parameters.
// Important: make sure your 'From' address is an e-mail address,
// not just a heading. Otherwise, no mail will be sent.
// Originally I used the "host" and "auth" parameters, but they
// don't seem to be necessary.

$headers['From'] = 'Ann Arbor District Library ';
$headers['Subject'] = 'Ann Arbor District Library card renewal';
// $params["host"] = 'blooregard.aadl.org';
// $params["auth"] = "TRUE";

// This is the loop. Each $line contains
// the e-mail address and expiration date.
// The e-mail address is $line [0].
// The expiration date is $line [1]. This is TRIMmed.
// The $message has the expiration date embedded in it.

foreach ($linearray as $mailarray)
{
$line = explode ("|", $mailarray);
$exdatetrimmed = trim ($line [1]);

$message = "Your library card from the Ann Arbor District
Library\r\nis due for renewal on ".$exdatetrimmed.".
Please bring your \r\ncurrent picture I.D. and proof of
address to the Circulation\r\nDesk at any AADL location
( http://www.aadl.org/aboutus ) \r\nto update your
resident card. Non-residents will also need\r\nto pay
with cash or check for the renewal period.\r\nBusiness
card holders, please bring a current pay stub\r\nfrom the
business authorizing the card. Thank you.";

// These are more PEAR mail parameters, and the mailing command.
// The 'To' header and the $recipients are both $line [0].

$headers['To'] = $line[0];
$recipients = $line [0];
$mail_object =& Mail::factory ("mail", $params);
$mail_object -> send($recipients, $headers, $message);
}
?>

Graphic for blog posts

Blog Post