Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript rule to check Mail against blackhole lists Apps
Do you use Apple's Mail program? Do you like it's junk filter, but wish it were just a bit better at catching spam? Well, this hint contains an AppleScript Mail filter (it's called SpamHolio, download (8KB)from macosxhints.com) that checks each new email's originating IP address against various real-time black hole lists (RBL) of known Spammers and Open Relays (ie. Spamcop, SPEWS, ORBS). If the sender's IP is listed in one of the checked against RBLs, the email is marked as junk and moved into the Junk mailbox for you.

This is a nice compliment to the built in Junk Filter which can occasionally miss new variants of spam that others have already discovered and reported to a RBL. You can think of this as a way of tapping into the insight of a larger pool of spam screeners beyond yourself. Just create a new filter that uses the following rules:
  If [All] of the conditions are met:
  [Sender is not in my Address Book]
  Perform the following actions:
  [Run Apple Script]
On the last step, you'll be asked to choose the location where you've saved the script. Ideally, you would prioritize this filter below the built in Junk filter in case it misses a spam that is otherwise known to the black lists (as defined in the AppleScript). For testing purposes (to make sure it is working well), you can put it above the built in Junk filter in the filter processing order to better keep tabs on what it is catching.

[robg adds: I've been running this script for a few hours now, and it's quite impressive. I usually receive anywhere from 150 to 200 spams a day, with Mail catching about 80% to 90% of them. Unfortunately, that means anywhere from 15 to 40 or so junk mails left in my inbox.

I've received about 20 since installing SpamHolio, and between it and Mail's junk filter, not a one has made it into my inbox! Read the rest of the article for some important information on customizing the filter. In addition, you'll have to edit the script if you have renamed you Junk Mail box (I have renamed mine to "zzz Junk," so it drops to the bottom of the list).]

User definable options (requires editing of the SpamHolio AppleScript):
  • If you would like not to be prompted with a dialog box that an email has matched a RBL entry, just set the PromptLevel to 0 (zero).
  • If you would like to add additional RBL's to check each new email against, just add the RBL's URL to the list defining BlackListsToCheck. I have only tested this script using the three in the script source, so use of other RBL's may require additional changes to the nslookup output parsing code.
This isn't very elegant AppleScript code, but it was my first AppleScript program and I hope others find it useful. I plan to add additional features in the future such as: a GUI preference configuration panel, more sophisticated and faster IP parsing, and more generalized and intelligent nslookup output parsing. Feel free to add to the code and improve it as you see fit; any suggestions or tips/code optimizations would be appreciated.

If you really like this AppleScript, please contribute some money to worthy organizations like SpamCop or C.A.U.S.E. or some of the other valiant anti-spam organizations out there.
    •    
  • Currently 2.40 / 5
  You rated: 1 / 5 (5 votes cast)
 
[17,463 views]  

An AppleScript rule to check Mail against blackhole lists | 44 comments | Create New Account
Click here to return to the 'An AppleScript rule to check Mail against blackhole lists' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript rule to check Mail against blackhole lists
Authored by: dave@mmu on May 27, '03 10:13:53AM

Well, i've put into my Mail rules, now tomorrow morning i'll see how many penis enhancements and ball enlargening emails i get that have slipped past the usual Junk filter..
(Why the hell would i want bigger balls anyway? Who thinks these things up? It's a funny old world)
Dave

---
Dave L



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: jnrhacksaw on May 27, '03 05:38:57PM

I'm a bit of a dumbass, how do I apply/install this script to the Junk rules or whatever I have to do.

Thanks in advance

BTW I find Mails junk filtering pretty good, I still have to manually check the Junk mailbox to make sure no 'genuine' mail gets junked. Hopefully this should make it better.

Rich



[ Reply to This | # ]
Steps...
Authored by: robg on May 27, '03 07:03:36PM

It's pretty well laid out in the text, but basically, save the script somewhere (after expanding the .sit file), then create a new Mail rule (Mail -> Preferences -> Rules tab). Set the conditions as shown above, and in the last step, point to the saved script on the hard drive.

That's it...

-rob.



[ Reply to This | # ]
Steps...
Authored by: jnrhacksaw on May 27, '03 10:54:02PM

Thanx

I got a little confused there, hadn't had my coffee at that stage.


Cheers


Rich



[ Reply to This | # ]
Steps...
Authored by: robosapien on Sep 03, '06 12:03:42AM

test



[ Reply to This | # ]
Steps...
Authored by: robosapien on Sep 03, '06 12:04:45AM

test



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: robosapien on Sep 03, '06 12:12:55AM

test



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: robosapien on Sep 03, '06 12:01:13AM

test



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: bluehz on May 27, '03 11:00:24AM

The only problem I see with this hint is those "blacklist" services and open relay lists. They are not always accurate and impossible to get your up removed from. A good example. I have my own mailserver running on our LAN, its on a cable connection (yeah I know...) and the because so many people on these cable services have poorly configured mailserver, don't know what they are doing or in general ar just idiots (sorry - venting) - those blacklists and open relay lists include WHOLE BLOCKS of IP's owned by cable companies. So because of the ills of many, I am blacklisted. This is clearly evident when you try to send something to someone on Earthlink - they use the blacklist services and will return mail undelivered if you try to send to someone on Earthling. If you must use spam control - I recommend taking a whitelisting strategy over blacklisting. I recommend setting up TMDA - its a radical approach to spam control - but very effective. TMDA uses whitelisting and tagged messages. From the TMDA site:

* TMDA's Whitelist-centric Strategy   ``Deny everything that is not explicitly allowed''
* Traditional Blacklist-centric Strategy   ``Allow everything that is not explicitly denied''

http://tmda.net



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: msk on May 27, '03 03:53:24PM

The posted AppleScript instructions are for a whitelist based system. After you run the email through the whitelist you got to do something with the stuff that does not match the whitelist. You either trash it, look it up in a black list, or send a challenge response (the latter can be implemented directly in OS X Mail or Eudora just using the filters).

However, whitelists are of limited value, spammers already sort email addresses by domain and use related email addresses as the from address to bypass whitelists--ineffective if your domain is yahoo or aol but if everyone in your domain is on your whitelist you need a fancier whitelist system then just depending on the from address. You need a system that parses the headers, remembers what servers and message-ids each friend generates.

Also, a system like TMDA requires admin access to the server and not every server has the software available to implement TMDA.



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: DaveCC on May 27, '03 09:42:08PM

(Long Post/Rant)
I am the author of the script and I figured at some point there would be some criticism of RBL's. I feel that spam has gotten to be such a problem that a single individual cannot hope to manage a large influx of spam into his/her e-mailbox without some outside help. Using a RBL just gives you the knowledge base of what might be spam that is the aggregation of thousands of other individual's spam screening efforts.

The RBL's are just another tool in your arsenel against the big time suck that dealing with spam has become, it is however an imperfect answer/tool. It is true that some RBL's are a bit overzealous and list some IP's as spammer IP's that don't deserve such a label. However I feel given the neverending assault of spam against my humble e-mail address (which I've had for 6 years and I'm rather attached to it), I am willing to run the risk of missing a few e-mails from strangers to be able to access my e-mail box the way I want to. Those who really need to contact me (ie. those who I want to contact me) will always be able to do so e-mail or not. For the rest, they just better not look like spammers.

If you are concerned about the accuracy or aggressiveness of a particular RBL, you can just elect not to use them and use a less comprehensive RBL. There are lots of them out there.

I structure a multi-tiered solution to screen spam with filter rules like this, in this filter order:

1) If the sender is in my address book, I stop processing all filter rules. Apple's mail application makes it really easy to add senders to your address book and makes this filter very responsive/flexible and easy to keep up to date.
2) If the sender is one of various organizations I want e-mail to get through from (ie. my work/company, @apple.com, etc), I stop processing all rules and/or route e-mails to the appropriate sub folder.

These two are effectively a whitelist that leaves known prior e-mail contacts and trusted sender domains in my In box.

3) The defuault Junk filter catches about 80% of my spam. It uses some sort of adaptive pattern recognition, but sometimes can't respond well to new/novel forms of spam (and those crafty spammers are always tweaking how they do things to get through filters. Hmmmm....if I really opted in then why do you always have to try to engineer your stuff to get past filters? Wouldn't I have placed your domain into rule 2? Dammed Spammers : )
4) I place SpamHolio here after the default Junk filter. This keeps the RBL checks limited to those that might have snuck in under the Junk filter's radar thus saving time and the RBL server's resources. I think by rough estimate, SpamHolio is catching 50-57% of spams missed by the Junk filter for me.
5) Any additional anti-spam filtering rules. (ie. I also look for all variations of subscribe/unsubscribe/opt in/opt out in the message body and junk it if it matches).

This seems to work well for me. The RBL isn't my only spam solution, just another tool in the chain. Looking at my mail traffic in the past 3 months, I have had recieved approximately 150 legitimate e-mail items, my Spam Filters (SpamEaterPro running on a old PC checking my POP account every 5 minutes against rules and RBL's and block lists, then Apple's Mail app's Junk filter) have blocked over 7,700 pieces of spam with about 300 pieces getting through. Out of these blocked spams, the RBL's blocked these numbers of spam items for me:
SpamCop: 3,100, SPEWS: 579, list.dsbl.org: 35, multihop.dsbl.org: 92, ipwhois.rfc-ignorant.org: 27.

Now that I can get some RBL lookup capability in Mail, I can perhaps think of not being dependent on my old PC to help continually clean out my POP account. I could set up SpamAssasin to do this, but it is a rather involved process and my Mac is a laptop and not always on, so I'll keep SpamEaterPro up and running for now.

Given those numbers, am I so off base using a RBL? Or do you think I have the time to sort through over 3,600 pieces of spam that might have gotten through the filters in the last 3 months?

Dave Chen

---
I'm much calmer now that I don't use WinBlow$ anymore.



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: mgaiman on May 27, '03 11:45:19AM
Apple Mail uses Bayesian Filtering to block spam. But what does that really mean? Paul Graham, one of first men to put Bayesian Filtering to work against spam, has a great write up on it here

[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: tunesmith on May 27, '03 07:44:30PM

Actually, I don't think that has been confirmed. Bayesian usually works better. I think Mail uses semantic analysis. I don't have a link for an explanation of how that works.



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: jonahlee on May 27, '03 09:08:43PM

Seems to correctly identify SPAM, though it leaves it in my inbox, and doesn't move it to my JUNK folder even though it has not been renamed. Hmmm. Strange. The call seems correct in the applescript, but it doesn't move it to the SPAM folder.

---
- Jonah Lee



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: DaveCC on May 27, '03 09:46:57PM

You know, I've noticed this behavior crop up when I've run the script as a self running application/script. But it was working well as part of a filter rule. Don't known the reason for this. Any AppleScript experts out there care to tackle this?

Dave Chen

---
I'm much calmer now that I don't use WinBlow$ anymore.



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: DaveCC on May 27, '03 10:26:57PM

Found out why this behavior is occuring. You must have this filter script BEFORE the built in Junk filter for the message to be moved to the Junk folder by the Junk rule. Apparently, the AppleScript I'm using to move a message over to the Junk folder ISN'T working and the Junk rule is finding the message flagged as Junk and doing the job of moving it over.

Not Ideal as I would prefer this rule to execute after the default Junk filter to avoid excessive RBL lookups. Oh well, back to the drawing board. Anyone have any ideas on how to code this? I've already tried:

set mailbox of CurrentMessage to mailbox "Junk"
set mailbox of CurrentMessage to junk mailbox

Both seem to check out syntax wise, but don't seem to do anything.

Dave Chen

---
I'm much calmer now that I don't use WinBlow$ anymore.



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: jason mark on May 28, '03 07:19:10AM

Try:

set storage of current message to folder spamFolderName


You might want to also take a look at Spam Sieve. It has some nifty applescripts with it. Spam Sieve puts a junkmail filter in Entourage, for those of us who aren't on Mail.

You can find more info, including a shareware download of the tool, including some nifty Applescripts.

http://www.c-command.com/spamsieve/



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: jonahlee on May 29, '03 02:37:42PM
Nope

set storage of current message to folder spamFolderName

doesn't check syntax wise in script runner. I am trying the following now to see if it works.

set storageCurrentMessage to mailbox "Junk"

And no matter if I put the original script before or after the Junk filter I still get the SPAM's left in my inbox. Hopefully this will fix it.

---
- Jonah Lee

[ Reply to This | # ]

An AppleScript rule to check Mail against blackhole lists
Authored by: andyland on May 29, '03 05:10:29PM

I cannot get any of these scripts to move the mail to the Junk mailbox either. Doesn't matter if the rule is before or after the Junk rule, or any of the syntax that has been posted here. They do get labeled as Junk, but they are still sitting in my In box. Can someone please confirm that the are having the mails identified with this script actually moved to their Junk mailbox?

thanks,
Andy



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: jonahlee on May 31, '03 03:32:54PM

Even with these changes, it is still not moving the SPAM to the JUNK Mailbox. It just isn't working. Anyone have any ideas?

---
- Jonah Lee



[ Reply to This | # ]
Enhanced AppleScript rule to check Mail against blackhole lists
Authored by: msk on May 28, '03 12:25:06PM

The posted Applescript needed some major changes to work in my environment (multiple trusted MTA between me and the outside world and incompatibility with EIMS, Eudora Internet Mail Server (Mac only mail server good for 1 to 10,000+ users), used by hobbists through ISPs).

The changes make the script parse the received headers one at a time and lookup any untrusted IP addresses rather than just the first IP address from a Sendmail based server.

[code]
(* SpamHolio v0.6-msk
Real Time Blackhole list lookups for E-Mails in your In Box for OS X 10.2/Mail
Applescript by David C. Chen, released under GPL, May 27, 2003
Make sure that the Black Hole List you are checking against allows public use
before you use it, also make sure that you understand how a DNS query against
Black Hole List works and how it could effect your incoming e-mails.
Not responsible for any loss of data or any inaccuracies in processing e-mails.
This is FREEWARE, review and understand the source, use at your own risk!!!

modified May 27, 2003 by M. Kluskens
? parse out all Received headers (important if mail passes through several trusted email servers)
? parse out the IP address from Eudora Internet mail Server headers (EIMS)
? added trusted IP address list
*)

on perform_mail_action(info)

(* Prompt levels: 0=no dialog boxes, 1=show dialog boxes when Spam is found, 2=show all dialog boxes, 3 =debug/verbose *)
set ShowPrompts to 0

-- list of trusted IP addresses not to look up
set TrustedIPlist to {"127.0.0.1", "203.97.196.98", "219.88.68.80"}

set BlackListsToCheck to {"bl.spamcop.net", "relays.osirusoft.com", "relays.ordb.org", "blackholes.wirehub.net", "list.dsbl.org", "dynablock.wirehub.net", "dialups.visi.com"}

(* Perform a nslookup against various RBL blacklists as DNS queries by executing the following: *)
(* nslookup IP4.IP3.IP2.IP1.[blacklist], a result of 127.0.0.2 is ususlly indicative of a positive match *)
(* Some Blacklists: bl.spamcop.net, relays.ordb.org, orbs.dorkslayers.com, dev.null.dk, relays.visi.com
relays.osirusoft.com (a.k.a. SPEWS uses 127.0.0.4 as a positive match) *)

tell application "Mail"
(* Process messages in the IN Box *)

set NewMail to |SelectedMessages| of info
repeat with CurrentMessage in NewMail
set RawSource to source of CurrentMessage
-- separate out different headers to check more than just the first [] pair
set HeaderName to "Start" as string
set ResolvedIP to "Cleared" as string
set loopCount to 1
-- checking complete when Subject, Date, From, or To header encountered
repeat until (HeaderName = "Subject:" or HeaderName = "Date:" or HeaderName = "From:" or HeaderName = "To:")
set Header to paragraph loopCount of RawSource
set Headerstart to the (offset of ":" in Header)
if (Headerstart > 0) then
set HeaderName to (characters 1 thru Headerstart of Header) as string
-- append the rest of the header text to the header (plus any uninteresting headers)
repeat
set Header2 to paragraph (loopCount + 1) of RawSource
set HeaderStart2 to the (offset of ":" in Header2)
if (HeaderStart2 ? 0) then
set HeaderName2 to (characters 1 thru HeaderStart2 of Header2) as string
if (HeaderName2 = "Received:" or HeaderName2 = "Subject:" or HeaderName2 = "Date:" or HeaderName2 = "From:" or HeaderName2 = "To:") then exit repeat
end if
set loopCount to loopCount + 1
set Header to (Header & Header2)
end repeat

if (HeaderName = "Received:") then
(* Locate the Originating IP Address in the raw E-Mail header *)
-- Sendmail and others
set start to the (offset of "[" in Header) + 1
set finish to the (offset of "]" in Header) - 1
-- Eudora Internet Mail Server
if (start = 1 or finish = -1) then
set start to the (offset of "(" in Header) + 1
set finish to the (offset of ")" in Header) - 1
end if

if (start < finish) then

set IPAddress to (characters start thru finish of Header) as string
if (ShowPrompts > 2) then
display dialog " Relay's IP " & IPAddress
end if

if (IPAddress is not in TrustedIPlist) then
(* Parse the IPAddress text into its IP1.IP2.IP3.IP4 fields, starting from the end IP4 to IP1 *)
copy text (((length of IPAddress) + 2) - ((offset of "." in (reverse of characters of IPAddress) as string))) thru (length of IPAddress) of IPAddress to IP4
copy text 1 thru ((length of IPAddress) - ((offset of "." in (reverse of characters of IPAddress) as string))) of IPAddress to IPAddress

copy text (((length of IPAddress) + 1) - ((offset of "." in (reverse of characters of IPAddress) as string))) thru (length of IPAddress) of IPAddress to IP3
copy text 1 thru ((length of IPAddress) - ((offset of "." in (reverse of characters of IPAddress) as string))) of IPAddress to IPAddress

copy text (((length of IPAddress) + 1) - ((offset of "." in (reverse of characters of IPAddress) as string))) thru (length of IPAddress) of IPAddress to IP2
copy text 1 thru ((length of IPAddress) - ((offset of "." in (reverse of characters of IPAddress) as string))) of IPAddress to IP1

repeat with BlackList in BlackListsToCheck
set LookUpResult to do shell script ("nslookup " & IP4 & IP3 & IP2 & "." & IP1 & "." & BlackList)

(* Parse the tail end of the last line looking for a match *)

set resultoffset to (((length of LookUpResult) + 1) - (offset of ":" in (((reverse of characters of LookUpResult)) as string)))
copy text (resultoffset + 3) thru (resultoffset + 10) of LookUpResult to ResolvedIP

if ResolvedIP = "127.0.0." then
set ResolvedIP to "SPAM!!!" as string
else
set ResolvedIP to "Cleared" as string
end if

if (ResolvedIP = "SPAM!!!") then exit repeat
end repeat
end if -- ( IPAddress is not is TrustedIPlist)
end if -- ( start < finish )
end if -- ( Headername = "Received:" )
end if -- ( Headerstart > 0 )
set loopCount to loopCount + 1
if (ResolvedIP = "SPAM!!!") then exit repeat
end repeat -- until

(* If it was listed in the RBL Move message to Junk folder and mark as Junk mail *)
if (ResolvedIP = "SPAM!!!") then
if (ShowPrompts > 0) then
display dialog "Found SPAM listed on " & BlackList & "
Move Message to Junk Mail" & "

From: " & (sender of CurrentMessage) & "

Subject: " & (subject of CurrentMessage)
end if

set is junk mail of CurrentMessage to true
-- change this line to match your junk/spam mailbox
set mailbox of CurrentMessage to mailbox "Junk"

else
if (ShowPrompts > 1) then
display dialog ResolvedIP & " Sender's IP " & IP1 & IP2 & IP3 & "." & IP4 & "

From: " & (sender of CurrentMessage) & "

Subject: " & (subject of CurrentMessage)
end if
end if

end repeat
end tell
end perform_mail_action
[/code]



[ Reply to This | # ]
Enhanced AppleScript rule to check Mail against blackhole lists
Authored by: DaveCC on May 28, '03 08:04:39PM

Excellent, just the sort of more intelligent IP Parsing I was looking for (but wasn't good enough with AppleScript to do myself).

Is there a Typo with this line:
if (HeaderStart2 ? 0) then

As this does not compile. Haven't been able to try it out because of this.

Dave C

---
I'm much calmer now that I don't use WinBlow$ anymore.



[ Reply to This | # ]
Enhanced AppleScript rule to check Mail against blackhole lists
Authored by: msk on May 29, '03 02:07:17PM

Side effect of pasting AppleScript into these windows--some of the characters get messed up. In this case the character is do not equals (option-= on a Mac keyboard).

I sent Dave the actual script compressed in a StuffIt file and when I remember I'll post the code at <http://users.starpower.net/mkluskens/eims/>.



[ Reply to This | # ]
Enhanced AppleScript rule to check Mail against blackhole lists
Authored by: msk on May 29, '03 04:58:11PM

The > character can also be used in that location, as in:

set HeaderStart2 to the (offset of ":" in Header2)
if (HeaderStart2 > 0) then
set HeaderName2 to (characters 1 thru HeaderStart2 of Header2) as string



[ Reply to This | # ]
Enhanced script uploaded
Authored by: robg on May 30, '03 09:39:51AM
I have uploaded SpamHolioEIMS.sit to the macosxhints' download site, so just click that link to get the script.

regards; -rob.

[ Reply to This | # ]
Enhanced script uploaded still doesn't move to Spam!
Authored by: jonahlee on Jun 02, '03 10:17:35AM

So now I have the Enhanced Applescript installed and still while it correctly identifies SPAM that the built in SPAM checker misses, but it doens't move it to the Spam filter weather I have it placed before or after the built in SPAM filter. Has anyone else figure out the proper way to script to move mail into the Junk folder.

---
- Jonah Lee



[ Reply to This | # ]
Enhanced script uploaded still doesn't move to Spam!
Authored by: msk on Jun 03, '03 08:43:23AM

Perhaps if you renamed the Junk mailbox it would work better, it works at home and at work for me but my Junk mailbox is called "?Junk" and "Spam" (? is an opt-8 bullet).

Also, if you are using this over a dialup line you should reduce the number of blacklists to maybe one or two, otherwise your pop server will time out on you. Spamcop is a good choice for one.



[ Reply to This | # ]
Does not delete messages from server
Authored by: Pierre Igot on May 29, '03 05:33:05PM

This script seems to be pretty effective at detecting spam that Mail misses -- but in my case it causes Mail to fail to erase the messages from my POP server!

So I end up with multiple copies of the same messages flagged as spam by your script.

Not good :).

Cheers,

--
Pierre Igot
LATEXT - Literature & Visuals @ www.latext.com
BETALOGUE - Weblog at www.latext.com/blog/
"Apple Peel" Columnist @ Applelust.com

---
Pierre Igot
LATEXT - Literature & Visuals @ www.latext.com
BETALOGUE - Weblog at www.latext.com/blog/
"Apple Peel" Columnist @ Applelust.com



[ Reply to This | # ]
Does not delete messages from server
Authored by: DaveCC on May 30, '03 02:58:48AM

Not having this problem, however I have the following set under Preferences->Accounts->Advanced tab. I have Mail set to:
"Remove copy from server after retrieving a message" set at [Right Away]. Perhaps you have it set to leave a copy on the server and Mail is getting confused as to what e-mails it has already checked after running a Script as a filter rule? Possible bug? What are your Advanced Account settings for your POP account.

OK also, still working on figuring out how to get the SpamHolio script to move messages out of the In box to the Junk box consistently. Will get back to you folks with an update when I've figured it out.

Also, test driving the version posted above with the more sophisticated IP parsing above.

Dave C

---
I'm much calmer now that I don't use WinBlow$ anymore.



[ Reply to This | # ]
Does not delete messages from server
Authored by: Pierre Igot on May 30, '03 08:19:12AM

Hi Dave,

Thanks for the reply.

I have 18 different POP accounts, and ALL of them are set to delete mail from server "right away" after retrieving it. Sometimes Mail fails to delete the mail properly because of some kind of failure -- but it usually succeeds the next time.

This problem is different. Whenever a message is flagged by your script, it is NOT deleted from the server. Yesterday, after a few hours of using your script and checking my mail every 10 minutes, I had about 30 copies of each spam message I had received since installing your script, which correctly flagged them as spam and moved them to my Junk folder.

Clearly this is a systematic problem, and it is clearly caused by your script, because I deactivated the rule based on your script, and the messages in question got retrieved one more time and deleted properly on my POP servers.

Pierre
--
Pierre Igot
LATEXT - Literature & Visuals @ www.latext.com
BETALOGUE - Weblog at www.latext.com/blog/
"Apple Peel" Columnist @ Applelust.com

---
Pierre Igot
LATEXT - Literature & Visuals @ www.latext.com
BETALOGUE - Weblog at www.latext.com/blog/
"Apple Peel" Columnist @ Applelust.com



[ Reply to This | # ]
Does not delete messages from server
Authored by: rude1 on May 30, '03 01:10:58PM

Pierre,

I too have the same problem - but - at work the Spam Script works like a charm and does what it is suppose to. When I get home, and wake my powerbook from sleep, the script identifies the mail as Junk/Spam but doesn't delete from the server and re-downloads it over and over and over.

If I turn off the Spam script, the mail downloads once with no problems. I believe that somehow the script has an issue with my home-based ISP service ( SW Bell DSL ) and not with my office T1 connection.

If anyone has a fix, that would be greatly appreciated as I tend to get most of my spam on the weekends and late at night etc.

Regards,

Rudy



[ Reply to This | # ]
Does not delete messages from server
Authored by: DaveCC on May 31, '03 11:49:53PM

I have observed this behavior with just 1 e-mail so far. Not sure what is causing it, perhaps a problem with the time-out settings of your particular POP server? Maybe the delay involved in looking up the IP addresses against the RBL's is causing a time out on accessing the POP account and the subsequent delete command is ignored? Anyone know the POP protocol better that could comment on this?

Still having problems with the applescript moving the flagged e-mail into the Junk folder properly. Some people are getting it working, some are not. I have noticed that it USUALLY works, but sometimes (and no pattern is apparent) there is a problem and the mail is left in the In box. A bug in the Mail app or the AppleScript library? Still plugging away at it.

I was thinking that this AppleScript filter rule is a bit slow and a rudimentary solution for a rather complex issue. Maybe someone could look at writing a standalone RBL lookup plugin for Mail/app as a native Cocoa program. I know the latter is beyond me.

DaveC

---
I'm much calmer now that I don't use WinBlow$ anymore.



[ Reply to This | # ]
Does not delete messages from server
Authored by: msk on Jun 02, '03 08:20:01AM

I also have observed this problem, and I agree it seems to be a timeout problem with the POP server. For me it only happens at home over the dialup line to my ISP's server and never at work with the EIMS server I run.

My best guess is to reduce the number of Blacklist servers but I'm betting the problem is that one of the best and therefore first server listed is reacting slow.

An alternative would be to tell OS X Mail to leave your email on the server for a little while in the hope that that way it won't try to sent the delete command after your POP server has timed out.



[ Reply to This | # ]
Solved, the problem of moving e-mails to the Junk folder
Authored by: DaveCC on Jun 02, '03 08:18:54PM

Well, I've figured out why the SpamHolio Applescript isn't moving RBL flagged e-mails into the Junk folder reliably.

If you look in your ~/Library/Mail/Mailboxes directory, you will see that there is no actualy subdirectory for the Junk folder. I think the Mail application stores the Junk e-mails in another location which isn't accessible/addressable via applescript.

Those who have their Junk/Spam e-mails being dumped into a non-default location (ie. Spam or xxJunk) have noted that SpamHolio moved the flagged messages to their custom Junk folder.

I then figured that if I created a new mailbox (which I called Spam), and directed the script to move the flagged messages there, the line should look like this:

set mailbox of CurrentMessage to mailbox "Name_of_your_custom_Spam_Mailbox"

Now everything works just fine. My In box is now automatically cleared of spam/junk mail. Those discovered by Mail's built in rule get dumped into the Junk folder, those discovered by SpamHolio get dumped into the Spam folder.

I have my Mail filtering rules as such:
1) If Sender if in my address book, stop processing all filter rules.
2) If Sender is in one of my accepted domain lists, stop processing all filter rules.
3) (any other accept rules)
4) The Default Junk Rule plus an extra action that tells it to stop processing any further filter rules if a message is Junk.
5) Run the SpamHolio filter script.
6) (any other Spam rules, ie. I have one that looks for the various incarnations of Op-In/Opt-Out/Subscribe/Unsubscribe in the message body and moves the message to the Spam folder if it finds such text)

This way, SpamHolio only gets used if the Default Junk rule misses the spam message (less wear and tear on the RBL servers). If you want all your spam consolidated into the Junk folder automatically, I suppose you could switch the position of the SpamHolio rule to be before the Junk rule, so that the Junk rule will transfer the e-mail into the Junk folder (something my Applescript apparently can't do) for you.

Yaaaay, it works now!!!

Note, some people have noticed that by having SpamHolio check out alot of RBL's, you may end up with a time-out situation for the Mail application as it tries to delete the retrieved e-mail from your POP account's In box. This can result in multiple copies of the e-mail being checked ending up in your Spam mailbox. So pick your RBL's wisely and use them sparingly as in it probably isn't worth checking against like 10 RBL's. I use SpamCop, SPEWS, ORBS and SpamHaus which seem to give me a really good yield w/o severe time-out problems.

OK, long post, but that should do it.

Dave

---
I'm much calmer now that I don't use WinBlow$ anymore.



[ Reply to This | # ]
Solved, the problem of moving e-mails to the Junk folder
Authored by: jonahlee on Jun 03, '03 11:03:28AM

Yes, thank you, that does work. Hmm I wonder how you can script the actual JUNK mail box. I wonder if it is a problem that there are subcategories in it for each mail account you have?

---
- Jonah Lee



[ Reply to This | # ]
Duplicate E-mails
Authored by: jonahlee on Jun 05, '03 11:11:27PM

Well with the new script, yes it puts the e-mail in the new SPAM folder, but it doesn't erase it from the server, and I just keep getting the same e-mail again until I erase it. Anyone else having this problems?

---
- Jonah Lee



[ Reply to This | # ]
Duplicate E-mails
Authored by: DaveCC on Jun 07, '03 03:22:43AM

I think the general consensus is that this may be due to time out issues when accessing the POP server (ie. the connection with the POP server drops before the delete command is sussessfully sent so the command never makes it to the POP server) if you access ALOT of RBL lookups that may be a bit slow.

The solution is apparently to choose just 3-4 RBL's and find ones that give replies quickly to your IP lookup request. Try cutting down the number of RBL's used until this doesn't happen anymore. Most of us probably don't need to use all 8-9 RBL's listed.

Dave

---
I'm much calmer now that I don't use WinBlow$ anymore.



[ Reply to This | # ]
Solved, the problem of moving e-mails to the Junk folder
Authored by: tunesmith on Jun 12, '03 12:43:55AM

Well, to make it go into the real Junk folder with its subcategories, you could always do three rules.

Rule 1:
Regular Junk rule, with an extra action to stop processing further rules

Rule 2:
Spamholio rule, with the applescript edited so that it only sets the junk attribute without trying to store it

Rule 3:
Do the regular Junk rule *again*.

Seems like a dreadful hack, and I haven't tested it because I'm trying to do something else entirely, but I had to at least suggest it. Hope it works for someone.

tunesmith



[ Reply to This | # ]
Solved, the problem of moving e-mails to the Junk folder
Authored by: KenPishna on Aug 14, '03 04:52:41PM

I also have the spam messages not being deleted from my server. I am on a DSL connection and the check is very quick, so I don't think it's a time-out issue.

Has anyone had any success correcting this issue?



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: jrlittlejr on Dec 12, '03 03:01:48AM

Hi,

In the Mail app v1.3 for Panther, the Junk Mail filter is no longer in the general filters. You can set the Junk Mail filter by clicking the "Advanced" button from the Preferences -> Junk Mail settings. Does anyone know where the Junk Mail filter runs? ie before the other rules, or after them?

Also, has anyone setup SpamHolio v0.7 on Panther? Any problems with it? I'm testing it but not confident enough to commit to it 100%... I'm just moving the mail to another mailbox for later review and not setting up any autodelete rules.

Thanks!
Jim



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: robosapien on Sep 03, '06 12:10:08AM

test



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: robosapien on Sep 03, '06 12:15:09AM

test



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: robosapien on Sep 03, '06 12:18:21AM

test



[ Reply to This | # ]
An AppleScript rule to check Mail against blackhole lists
Authored by: robosapien on Sep 03, '06 12:20:22AM

test



[ Reply to This | # ]