C-Command Software Forum

Have to delete same spam messages multiple times

Michael,

Thanks for all your help in the past. The issue I’ve been having since getting everything set up with flagging messages, coloring them, etc. is that now when I choose a batch of messages to delete, I have to delete them twice. It seems like the first time the messages are marked as unread. I select them, hit delete, and the unread status goes away but the messages remain so I have to select and delete them again.

  1. Is there a way to get them to simply delete the first time?

  2. For the spammiest messages (blue and gray), is there a way to get them to simply delete on their own so I don’t have to select and delete them?

I have never heard of anything like that happening. Did you check for errors that Mail reported? Perhaps it would help to rebuild your Mail database. Or perhaps it’s due to a bug in Mail.

Yes, you can set it up so they go directly to the trash.

I will look into rebuilding the database but I have a feeling that’s not it. I should have done that before sending these screenshots but, if they’re showing up, here’s an example of spam messages in the Flagged folder first marked as unread. I selected all, hit delete, and they reappeared but this time as read. Selected all and deleted a second time and they finally deleted for good.

Clarification regarding my automatically delete question: is it possible to actually get the messages to delete as in bypass the trash and simply go bye-bye so I don’t have to select them in the Trash and hit delete?

Screen Shot 2015-06-04 at 8.10.45 PM.png

Screen Shot 2015-06-04 at 8.10.55 PM.png

The screenshot shows that the messages are in fact in the trash. So I think this is a display issue, where the messages are deleted but Mail is incorrectly showing them in the flagged smart mailbox. My guess is that rebuilding the database would help, since I think that’s how Mail determines which messages are flagged and/or deleted. Or, it might be a problem with the Spotlight database, as Mail uses that for some types of smart mailbox searches (though I wouldn’t expect it to use it for Flagged).

You can use this script to delete stored spam messages and bypass the trash. There is no way to instantly delete incoming messages without having them first go through the trash.

Hi Michael,

I’ve spent days trying to troubleshoot this problem so I don’t have to bother you but I’m totally stumped. You helped me properly identify the spammiest messages and put blue and gray messages in the trash. You also helped me with a script that will delete all those messages so I don’t have to manually select them in the trash and delete them. This works perfectly on my laptop. I recently got a new iMac and duplicated everything that’s on my laptop and everything works except the script to delete all the messages in the trash. I’ve confirmed settings are the same between the two computers multiple times but it’s still not working. Is there any way for you to help me troubleshoot this? It’s driving me bonkers.

What happens when you run the script? Does it stop with an error? Did you check the Console for error messages?

Nothing happens when I run the script. No errors…nothing, though Console is saying something about ‘maximum recursion exceeded’. There’s a little turning gear icon that pops up in the menu bar showing that the script is working but that’s about it.

Screenshot attached of what Mail looked like before I ran the script (same after as well) and pasted log from Console:

6/17/15 1:53:22.020 PM Mail[411]: open on /Users/dcoplan/Library/Mail/V2/Mailboxes/Deleted Messages.mbox/39A41546-C20B-41E1-9F49-BD195A6293F4/Data/6/4/Messages/46496.emlx: No such file or directory
6/17/15 1:53:26.602 PM avguard.bin[271]: “/Users/dcoplan/Library/Mail/V2/IMAP-camera@dancoplan.com@mail.dancoplan.com/INBOX.mbox/Deleted Messages.mbox/39A41546-C20B-41E1-9F49-BD195A6293F4/Data/5/3/Messages/35314.emlx” was not completely scanned (maximum recursion exceeded)
6/17/15 1:53:26.686 PM avlogwriter[259]: e[32m[INFORMATION]2015-06-17 13:53:26: bde4d2d2-495f-40b9-b40e-9ae0d5332728:52 Got: 61 for group localaccountse[0m
6/17/15 1:53:26.689 PM avlogwriter[259]: e[32m[INFORMATION]2015-06-17 13:53:26: bde4d2d2-495f-40b9-b40e-9ae0d5332728:52 Got: 61 for group localaccountse[0m
6/17/15 1:53:27.000 PM kernel[0]: process 809 set trusted
6/17/15 1:53:27.000 PM kernel[0]: Change trust on
6/17/15 1:53:27.000 PM kernel[0]: process name mdworker (pid 809)
6/17/15 1:53:30.826 PM avguard.bin[271]: “/Users/dcoplan/Library/Mail/V2/IMAP-camera@dancoplan.com@mail.dancoplan.com/INBOX.mbox/Deleted Messages.mbox/39A41546-C20B-41E1-9F49-BD195A6293F4/Data/3/1/Messages/13825.emlx” was not completely scanned (maximum recursion exceeded)
6/17/15 1:53:30.893 PM avlogwriter[259]: e[32m[INFORMATION]2015-06-17 13:53:30: bde4d2d2-495f-40b9-b40e-9ae0d5332728:52 Got: 61 for group localaccountse[0m
6/17/15 1:53:30.901 PM avlogwriter[259]: e[32m[INFORMATION]2015-06-17 13:53:30: bde4d2d2-495f-40b9-b40e-9ae0d5332728:52 Got: 61 for group localaccountse[0m
6/17/15 1:53:32.741 PM dcoplan[810]: SpamSieve [Discard Spam Script] Mail did not delete the messages: hnbg21801052dfafq@aquazymes.com
6/17/15 1:53:35.712 PM avguard.bin[271]: “/Users/dcoplan/Library/Mail/V2/IMAP-camera@dancoplan.com@mail.dancoplan.com/INBOX.mbox/Deleted Messages.mbox/39A41546-C20B-41E1-9F49-BD195A6293F4/Data/5/3/Messages/35314.emlx” was not completely scanned (maximum recursion exceeded)
6/17/15 1:53:35.800 PM avlogwriter[259]: e[32m[INFORMATION]2015-06-17 13:53:35: bde4d2d2-495f-40b9-b40e-9ae0d5332728:52 Got: 61 for group localaccountse[0m
6/17/15 1:53:35.802 PM avlogwriter[259]: e[32m[INFORMATION]2015-06-17 13:53:35: bde4d2d2-495f-40b9-b40e-9ae0d5332728:52 Got: 61 for group localaccountse[0m
6/17/15 1:53:36.364 PM avguard.bin[271]: “/Users/dcoplan/Library/Mail/V2/IMAP-camera@dancoplan.com@mail.dancoplan.com/INBOX.mbox/Deleted Messages.mbox/39A41546-C20B-41E1-9F49-BD195A6293F4/Data/3/1/Messages/13825.emlx” was not completely scanned (maximum recursion exceeded)
6/17/15 1:53:36.414 PM avlogwriter[259]: e[32m[INFORMATION]2015-06-17 13:53:36: bde4d2d2-495f-40b9-b40e-9ae0d5332728:52 Got: 61 for group localaccountse[0m
6/17/15 1:53:36.416 PM avlogwriter[259]: e[32m[INFORMATION]2015-06-17 13:53:36: bde4d2d2-495f-40b9-b40e-9ae0d5332728:52 Got: 61 for group localaccountse0m

Screen Shot 2015-06-17 at 1.53.06 PM.png

Your log excerpt included this line:

6/17/15 1:53:32.741 PM dcoplan[810]: SpamSieve [Discard Spam Script] Mail did not delete the messages: hnbg21801052dfafq@aquazymes.com

which means that the script told Mail to delete the message, and Mail did not report an error, but when the script checked the message was still there. Normally, the script will retry in this situation and report another error if deleting the message still didn’t work.

That seems to be from your anti-virus program. Perhaps it is interfering with the deletion in Mail. Have you tried disabling it?

How are you running the script? Have you tried running it directly in Script Editor?

I was having this problem before I installed the anti-virus software.

I’m running the script by choosing it from the little script icon in the menu bar on the right that is present at all times. I’ve attached a snapshot.

Any idea why this works perfectly fine on one computer but not the other one?

Screen Shot 2015-06-17 at 2.50.29 PM.png

I don’t know. I’ve added some debug logging to the script so that we can see more of what it’s doing. Please download a fresh copy of the script, change the first line to enable debug logging, and run it from Script Editor. This should produce a lot more information in Console.

This is what I get now when I run the script:

6/21/15 7:37:11.000 AM kernel[0]: process firefox[476] caught causing excessive wakeups. Observed wakeups rate (per sec): 247; Maximum permitted wakeups rate (per sec): 150; Observation period: 300 seconds; Task lifetime number of wakeups: 266954
6/21/15 7:37:11.225 AM com.apple.xpc.launchd[1]: (com.apple.ReportCrash[547]) Endpoint has been activated through legacy launch(3) APIs. Please switch to XPC or bootstrap_check_in(): com.apple.ReportCrash
6/21/15 7:37:11.226 AM ReportCrash[547]: Invoking spindump for pid=476 wakeups_rate=247 duration=183 because of excessive wakeups
6/21/15 7:37:11.716 AM spindump[462]: Saved wakeups_resource.diag report for firefox version 38.0.5 (3815.5.25) to /Library/Logs/DiagnosticReports/firefox_2015-06-21-073711_Dans-iMac.wakeups_resource.diag

And then I ran it again but no logs in Console. Actually when I first ran it the little gear wheel in the menu bar spun briefly but nothing came up in Console and then the above came up after a little while.

I have the script in Macintosh HD > Users > dcoplan > Library > Scripts > apple-mail-discard-spam.scpt

Is this correct? Or should it be in the same folder as the apple-mail-server-junk-mailbox.scpt? If I put it in there then it doesn’t show up under the script icon in the menu bar.

Please make sure that you enable debug logging, as described on the script page.

Yes, then it will show up in the Script menu for all applications. Or you could put in in:

~/Library/Scripts/Applications/Mail

So that it only shows up for Mail.

Here’s the latest Console messages:

6/22/15 10:02:06.119 PM dcoplan[2174]: SpamSieve [Discard Spam Script] Found 0 messages in mailbox “Spam”.
6/22/15 10:02:06.817 PM dcoplan[2175]: SpamSieve [Discard Spam Script] Mail deleted all the messages from the trash

Mail deleted nothing from the Trash and there are 58 messages in there flagged, unread, and colored blue or gray.

This indicates that the script found no messages in the Spam mailbox. Therefore, it did not do anything. It does not delete messages that were already in the trash before you ran the script, only the messages that it moved from the Spam mailbox.

On my laptop, the computer with which I’m not having any issues, the script deletes the messages from the Trash no problem. I made sure that there weren’t any messages in any Spam folders of any kind, ran the script, and sure enough it deleted the flagged messages. The trick now is to get the same result on my iMac - a complete mystery as to why it’s not working.

If the script is deleting messages from Trash, this probably means that you’re using an old version of the script. Newer versions only delete messages that were first moved from Spam, amongst other improvements for increased compatibility.

I’m using the exact same version of the script on both machines. I confirmed everything by emailing myself the script from the computer that’s working, putting it in the exact same location, restarting Mail and still nothing. Yet when I go to the machine that’s working, it works like a charm. For what it’s worth, the OS is the same on both machines: 10.10.3.

I don’t know what to make of that because recent versions of the script do not delete messages that were in the trash before running the script. Could you e-mail me the script file that you’re using?

Thanks for sending the script file. I’m not sure which Mac this was from, but it is not the current version of the script and does not have debug logging enabled.

I just sent you an email with Console messages.

Last night I updated both computers with the latest version of the script and turned debugging on. I verified once again that everything is identical between the two machines with respect to the other scripts as well (Server Junk Mailbox SpamSieve, SpamSieve [Score], SpamSieve [Blue][Gray], and SpamSieve [Spam]). I ran the script on the machine that is not working and…it didn’t work. I ran it on the machine that is working and it works.

I’m about to give up but also willing to try whatever you suggest to figure out why this is happening and get it resolved.