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.

  • BTW, I’m trying to replace the IFTTT gmail trigger that went away recently. I want to be able to trigger applets when my garage door opens based on the email it sends.
    – hepcat72
    Apr 30, 2019 at 11:17
  • It’s actually working now but I don’t know what fixed it... :/
    – hepcat72
    Jun 28, 2019 at 17:08


You must log in to answer this question.

Browse other questions tagged .