This Python script is intended to work with Alma (ExLibris) to notify users by e-mail that their account is about to expire.
- (Linux) Server - not tested on Windows!
- Python 3.6 or higher
- Mail Transfer Agent (e. g. Postfix)
Warning
Make sure your server is configured properly for sending e-mails. Otherwise, the notifications could be treated as spam. - Alma from ExLibris, an Alma API key with read permissions for the Analytics API and an appropriate Analytics report (see comments for "path" config in config file for more information)
-
Clone the repository
git clone https://github.com/AKBibliothekWien/alma-notify-expiring-users.git
-
Change into the directory of the repository
cd alma-notify-expiring-users
-
Create a virtual environment
python3 -m venv .venv
-
Activate the virtual environment
source .venv/bin/activate
-
Upgrade
pip
python -m pip install --upgrade pip
-
Install the python dependencies
python -m pip install -r requirements.txt
- Copy the
config.example.py
toconfig.py
- Adjust all configs to your needs (see the comments in the config file)
-
In the config file, set your test e-mail address to the config
to_email_test
. Every e-mail that would normaly be sent to a user will now be sent to this e-mail address. -
Run the script and check if everything works as expected:
-
Within the path of the repository, activate the virtual environment if not already activated.
source .venv/bin/activate
-
Run the script and check your e-mails.
python notify-expiring-users.py
-
-
When testing is finished, comment out the
to_email_test
config or set it toNone
. Now the e-mails will be sent to the real users.
-
Use a cronjob that runs the script once daily.
Warning
If the cron job runs multiple time per day, the users that are about to expire will receive multiple e-mails. Therefore it is recommended to run the job only once a day. -
Cronjobs can be run for a specific user or from the systems
/etc/crontab
file. Choose which way is the most appropriate for you. -
A cronjob in
/etc/crontab
that runs the script every day at 06:00 o'clock could look like this:0 6 * * * root $path_to_repo/.venv/bin/python $path_to_repo/notify-expiring-users.py
Warning
Make sure that you use the python from your virtual environment!