Last active
December 8, 2023 22:04
-
-
Save poritsky/7358136 to your computer and use it in GitHub Desktop.
Apple Mail Rules to FastMail Advanced Sieve Rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Apple Mail Rules to FastMail Advanced Sieve Rules | |
Jonathan Poritsky, candlerblog.com | |
November 8, 2013 | |
--- | |
For more information on FastMail server rules (and requisite warnings) read Gabe Weatherhead's piece on transitioning to server-side mail rules: | |
http://www.macdrifter.com/2013/11/server-side-mail-rules.html | |
*) | |
set l to {} | |
set prefix to "INBOX." --IMAP Prefix. By default this is "INBOX." on FastMail. You probably shouldn't change this but if you've made it this far all bets are likely off. | |
## IMPORTANT | |
## These next two settings will need to be customized. | |
set r to "Archive Rule" --Apple Mail Rule from which to pull addresses | |
set f to "Archive" --Name of folder to move messages to | |
tell application "Mail" | |
set m to properties of rule conditions of rule r | |
repeat with v in m | |
set p to the expression of v | |
set l to l & "\"" & p & "\"," as list | |
end repeat | |
end tell | |
set addresses to l as text | |
set SieveRecipe to "if header :contains \"from\" [" & addresses & "] {" | |
set CleanSieve to (do shell script "echo " & quoted form of SieveRecipe & " | sed 's/,[^,]*]/]/'") | |
return CleanSieve & " | |
addflag \"\\\\Seen\"; | |
fileinto \"INBOX." & f & "\"; | |
stop; | |
}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment