Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

travisjcoleman

macrumors newbie
Original poster
Jan 30, 2016
2
0
Hi guys,

I'm currently trying to zero my inbox since there are over 50k mails and 4/5 of them spam only, I'd like to filter all them spam by using rules within the Mail.app.

The problem here is that I already collected almost 100 different email addresses which I can't put into rules.. that would be too much work. The surface of creating rules in mail.app on OS X is not really the best for heavy users.

I tried to open the user library and the files where the rules are stored. Adding all the mail addresses in there is impossible since there is a code generated by mail for every single email address you add to a rule.

Do you guys have an idea how I could solve my issue? server side rules or unsubscribing is not an option unfortunately.

Thank you guys.
 

kryten2

macrumors 65816
Mar 17, 2012
1,115
99
Belgium
The problem here is that I already collected almost 100 different email addresses which I can't put into rules.. that would be too much work.Do you guys have an idea how I could solve my issue?
Thank you guys.
You can script the Mail application with AppleScript. Here's an example script. The script will create a new mail rule named SpamTest2 with 100 rule conditions in it. As I don't have 100 real email addresses to play with I just made them up with the repeat loop. The important part here is that emailAddressList starts as an empty list and after the first loop it gets filled with the fake email addresses eg {"bob1@hotmail.com","bob1@hotmail.com",...,"bobn@hotmail.com"}.

Code:
set emailAddressList to {}
set mailSuffix to "@hotmail.com"
repeat with i from 1 to 100
    set end of emailAddressList to "bob" & i & mailSuffix
end repeat

tell application "Mail"
    set spamTest2 to make new rule with properties {name:"SpamTest2"}
    repeat with emailAddress in emailAddressList
        make new rule condition at end of spamTest2 with properties {expression:emailAddress, rule type:from header, qualifier:does contain value}
    end repeat
end tell

You just need to get your real email addresses into the emailAddressList variable eg
Code:
set emailAddressList to {"Steve Jobs@apple.com","Bill Gates@microsoft.com",...}
You can dump those real addresses into a text file with 1 address per line and read the file contents to build your list.
You can see that I didn't put those addresses into the list manually. When you have that list you would use the example script like this :

Code:
set emailAddressList to {"Steve Jobs@apple.com","Bill Gates@microsoft.com",...}

tell application "Mail"
    set spamTest2 to make new rule with properties {name:"SpamTest2"}
    repeat with emailAddress in emailAddressList
        make new rule condition at end of spamTest2 with properties {expression:emailAddress, rule type:from header, qualifier:does contain value}
    end repeat
end tell

ScreenShotMailRule.png

Note : Tested on Mavericks
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.