Rescue Good Messages Script issue

The Rescue Good Message script is not processing some emails in the Junk folder. This just started a few weeks ago. Many are processed properly, but some aren’t processed at all. They do not show up in the Log window and remain in the All Junk folder in Apple Mail. When I move the skipped emails to trash, the background is white. The junk emails are marked Unread.

It’s now over 1/2 hour after I received 2 junk emails, and they remain in the All Junk Folder. I have set the app to run every 5 minutes. I just tried running the script in Apple Script, and 1 of the 2 junk emails was moved to Trash, but the other remains.

After I wrote the above text, the remaining junk email was moved to Trash. I have set the script properties such that blue, gray, purple, red orange and yellow are all sent to Trash.

It seems that this behavior started when I updated to version 26 of the Mac OS, but I’m not sure.

Are you running the Rescue Good Messages script via a Mail rule or as a standalone app?

If you look in the Log window, did it say anything about that second message at the time the first one was processed?

I’m running it as a stand alone app. Then I tried running the script. Running the script moved the newest one to the trash, and the stand alone app moved the second one to Trash while I was watching.

I don’t recall the emails involved when this happened, so I can’t answer your second question.

A few weeks ago I had about 20 emails in my Junk folder, and they had been building up for hours. I ran the script and nothing happened, so I just moved them all to the trash. Then things mostly worked as they should. It’s an intermittent problem, and I doubt that the script is responsible.

However, right now there is one email in All Junk which is dated 13 minutes ago, and the app is set to run every 5 minutes. Here’s a screenshot:

I opened the script editor and ran the script. The email was sent to the trash. But the app should have done that earlier.

This is the modified script to have the app run every 5 minutes:

on idle
– This is executed periodically when the script is run as a stay-open application.
my filterServerJunkMailboxes()
return 60 * 5 – Run again in 5 minutes.
end idle

I think the way App Nap works has changed on Tahoe. I wonder if maybe macOS is putting the script app to sleep so that it never gets any processor time. Does clicking on the script app’s Dock icon get it to process the messages?

It’s also possible to enable debug logging at the top of the script. Then you could open a search in the Console app for Apple Mail Rescue Good Messages and see when the script is running and what it’s doing.

I does seem like the Mac OS has put the app to sleep. Clicking on the script app’s Dock icon doesn’t seem to do anything.

I tried to turn on debugging before, but couldn’t find anything in the Console log. I’ll try again.

Thanks for your reply. If no one else is having a problem, I have to think it’s something I’ve done, but I have no idea what that might be.

If you click and hold, does it say that the app isn’t responding?

You have to save and relaunch the app to see the change.

Another option would be to have Mail run the script using a rule, since Mail won’t get put to sleep with its window open.

No, it doesn’t.

I can’t remember what the messages in question were, so I can’t tell.

Everything worked fine overnight.

That would suggest that it’s either asleep or encountering errors. So I think the next step is to check the log when the problem recurs.

I changed the debug status and replaced the app yesterday. I searched for “rescue” in Console and found nothing.

Must be an Mac OS issue. Thanks for all your help. I really enjoy using your app.

Please make sure that:

  1. You have your Mac’s name selected at the left of the Console window.
  2. You enter the search term at the top right where it says Search.
  3. You click the Start streaming button at the bottom.
  4. All Messages is selected at the top of the window.
  5. You do this before launching the rescue app and leave the search open so it can capture subsequent log entries.

I was watching my Junk folder and noticed again something odd. There were 2 emails in Junk, not yet processed by the Rescue app. The newest disappeared to the trash, but the older one was untouched. 5 minutes later, 10 minutes after the email appeared, the older email was sent to Trash.

So the script app processed the newer one, skipped the older one, but then later processed the newer one.

In the picture below, the older email is highlighted. It was received at 10:50:49 AM, and processed at 11:00:59 AM, 10 minutes later.

The email highlighted above should have been processed when the email highlighted below was processed, at 10:53:43 AM.

I thought you might find this interesting, but I’ve wasted too much of your time on this. It’s not a Spam Sieve issue, but a Mac issue.

Thanks. I didn’t know how Console worked.

In this picture there are 2 emails in Junk. The first should have been already processed, and the second was processed a litlle later.

PastedGraphic-1.tiff

Now only the old Junk email is present.

Very strange behavior.

Here’s what’s in the Console window now:

So, the app is running, just running incorrectly and inconsistently.

It looks like Mail is reporting errors. If you click on the message in Console it should show some more information.

Sorry, I had paused and quit Console. The tardy email in Junk is now in the trash, and was processed 1/2 hour after it arrived and was skipped multiple times.

I’ll look for another skipped junk email and click on it if it happens again.

I got one. I have no idea what this means, but it processed properly. The spam was sent to trash.

This error typically means that some other software (or person) moved the message while SpamSieve was in the middle of working with it.

I had opened and was reviewing the Spam Sieve log, and saw an email in the Junk folder. The time limit passed when that email should have gone to Trash, so the script app had skipped it. I switched to another app, and when I checked back some time later, that email had been sent to Trash.

I have the script app set up to run every 5 minutes, but this time it took 9 minutes. From the log:

Date Logged: Today at 11:17:21 AM

Subject:	Bill Gates: "It's over for Alzheimer's" ✨ 🧠 🔥
From:	CNN <59javht1919974@gomerblog.com>
Date Sent:	Today at 11:08:36 AM
Date Received:	Today at 11:08:37 AM

I’ll try the same steps again when I can.

If you enable debug logging in the script, it will report in Console every time it runs, so you will be able to see which schedule macOS is running it at and when it’s finding new messages to filter. It may take some time between when it queries Mail for new messages and when the message is actually processed and logged to the Log window.

I think some code I inserted some time ago might be causing this intermittent problem. I’ve commented the change out in the code below. I can’t recall right now why I added it, but it worked for a long time, and still works most of the time.

I’ve exported the script, with my changes removed, as an app, and will keep an eye out for any problems.

As always, operator error is most likely (mine).

	if _isSpam and pMarkSpamMessagesRead then
		set _message's read status to true
	end if
	set _moveToTrash to my colorMessageAndDecideIfShouldMoveToTrash(_message, _score)
	if _moveToTrash then
		delete _message
		-- start my insertion
		-- 		if pMarkSpamMessagesRead then
		-- 			set _message's read status to true
		-- 		end if
		--		-- end my insertion
	else if _isSpam then
		my debugLog("Leaving spam message in Junk: " & _message's subject)
	end if

Yes, that seems like it could cause problems because the _message reference probably won’t be valid after the message has been moved to the trash.