I have a Perl script that uses
MIME::Parser which simply reads new emails from an IMAP server and saves any attachments to disk.
My question is: what is the best way to run this script as soon as there's new email? I can use cron to periodically run the script, I could check every few seconds even, but I suspect there is a better way.
Ideally I would act upon the receiving of an email immediately, like a system event. What are common software and techniques to achieve this? I'm using a Debian system.