macOS Mail has built-in rules and filters that you can use to manage all of your accounts. These run whenever your Mac is awake and connected to the internet and allow you to do anything from set the background color of emails in the list to executing AppleScript!

Read it on The Sweet Setup