I wrote an AppleScript to send an email with a hashtag in the subject to [email protected] and I created a Rule in Apple Mail to run the AppleScript when a new mail is from a specific sender and the subject contains a term I entered. The rule also marks the email as read and moves it to the trash.
The rule works great when I test it by applying the rule to selected messages, but when I receive an email that matches the rule over night or when I’m not actively using the computer, the email gets marked as read and is moved to the trash, but the script doesn’t appear to run or somehow otherwise silently fails.
My computer is always logged in and is never set to go to sleep. As proof, long running scripts I run on the command line run continuously regardless of how long I’m away.
So I’m guessing that Applescripts are suspended when the screen is locked or else Applescripts will not launch while the screen is locked? Or perhaps the Mail app (which the AppleScript uses to send the email) will not send emails when the screen is locked?
I’m not sure when the received email is marked as read and moved to the trash, but I know it happened at some point. I assume it happened while the screen was locked or else I suspect that AppleScript would have run correctly as it does when I test it.
Does anyone know where the rule is likely failing and how to make it work regardless of the screen lock? I need it to happen immediately upon receipt of the triggering email.