TIL how to trigger notifications in Thunderbird for specific emails
⋅ 2 minute read ⋅ 398 words
Some training sessions in my triathlon club are very popular. The weekly swim sessions in the winter and some of the longer rides on summer weekends are limited to a few people per group. There are usually five groups for different fitness levels. People in my club are really fast at signing up, but there are always some who drop out a day or a few hours before the training session. If I didn’t sign up quickly enough I usually try to grab one of those last-minute spots. But even for those you have to be quick. I usually have between 1-5 min to react after a drop out before it gets snatched by somebody else.
Problem
The notifications for available spots usually come during work hours via email from the booking system. I want to set up the email client on my MacBook to send me a notification as soon as such an email arrives.
Solution
There is no built-in feature for notifications for specific emails. But I managed to set it up using the Thunderbird Extension FiltaQuilla and an osascript one-liner.
FiltaQuilla extension
In Thunderbird install the
FiltaQuilla
extension. This adds a number of new email filter actions to Thunderbird. After installation, navigate to the FiltaQuilla preferences and check the Run Program filter action. Then restart Thunderbird.
Notification display script
Create the script that later runs when a certain filter rule fires. I created ~/scripts/thunderbird_alert.sh with the following content
#!/bin/bash
osascript -e 'display notification "A new spot opened up. Check your inbox." with title "Mail from Triathlon Club" sound name "Glass"'
Then add execution rights to the script with chmod +x ~/scripts/thunderbird_alert.sh. I tested the notification by running the script: ~/scripts/thunderbird_alert.sh. You should see it appear in the top right corner of your screen. Mine looks like this:
Set up filter rule
Back in Thunderbird, go to Tools -> Message Filters -> New.... Give the new rule a name, then set match on From is no_reply@triathlon.club. For the action select Run Program and paste the path to the notification script /Users/myname/scripts/thunderbird_alert.sh.
That’s it. Every time a new email with that address arrives in Thunderbird, the filter rule fires the script and I see the alert that a spot is available. Compared to previous weeks my booking rate for popular sessions has gone up a lot.
If you have any thoughts, questions, or feedback about this post, I would love to hear it. Please reach out to me via email.
Tags:#email #script