How to move to trash folder automatically?

I’m not sure how to run the script directly, I can run it in the Script Editor, to which nothing happens if that’s what you mean.

SpamSieve (for me) works when all of the mail is in the Inbox. When I say works for me I mean SpamSieve will move the spam in the Inbox to the Trash folder automatically.

If the email ends up in the Junk folder (like it’s been doing), SpamSieve doesn’t do anything to them, because (presumably) AOL already filters.

So my only goal - is to have ALL emails (new or spam) go to the Inbox so SpamSieve can filter them (and thus as stated in the title of this thread “move to the trash folder automatically” - by filtering them).

Yes, you said yesterday that you ran it in Script Editor and got output in Console.

The screenshot that you posted today only showed the log entries for the On My Mac Junk mailbox, which showed there were zero messages in that mailbox.

But presumably the messages that you want to be filtered are in a server Junk mailbox for one of your accounts. What does the Console log say about that mailbox when you run the script?

If you don’t see that mailbox in the log, it’s most likely because Mail is not configured to use that server mailbox as the special Junk mailbox. You can set it in Mail’s Accounts settings.

That’s not how it works. The messages caught by the server filter are supposed to stay in the Junk mailbox, and the script filters them from there (moving good the Inbox, very spammy to the Trash, and coloring the backgrounds of the ones that are spam).

So there’s no AppleScript made that can move the spam that AOL puts in the Junk folder into the Inbox automatically for SpamSieve to filter?

Because the only way I’ve been doing it is by either physically moving the Junk mail to the Inbox or apply a rule that does the same so SpamSieve can filter color it & move them to the Trash.

Otherwise SpamSieve is only catching what AOL didn’t filter, leaving an overcrowded Junk folder.

There’s no need for a script to move spam messages from Junk to Inbox because the rescue script will automatically filter them while they’re in Junk. You can also manually filter them while they’re in Junk using the Filter Messages command.

If the rescue script is not working for you, please see my previous comments/questions about checking the Junk mailbox setup and Console log.

  • I have Console open, I select start.

  • I have 2 emails in the Junk folder, that are Unread, and right click and select “Apply Rules”. (Nothing happened, they are still unread and didn’t move)

  • I go to the Console and stop to see the log and see this (ordered from first to last via the Time column. And again, HIDINGEMAIL is deliberately hiding my email):

SpamSieve [Apple Mail Rescue Good Messages] Start checking mailbox “On My Mac” / “Junk (HIDINGEMAIL)”:

SpamSieve [Apple Mail Rescue Good Messages] Total messages in mailbox “On My Mac” / “Junk (HIDINGEMAIL)”: 0

SpamSieve [Apple Mail Rescue Good Messages] Getting unprocessed messages in mailbox “On My Mac” / “Junk (HIDINGEMAIL)”:

SpamSieve [Apple Mail Rescue Good Messages] Messages to process in mailbox “On My Mac” / “Junk (HIDINGEMAIL)”: 0

SpamSieve [Apple Mail Rescue Good Messages] Finished checking mailbox “On My Mac” / “Junk (HIDINGEMAIL)”:

Those are the 5 logs that I saw on the Console, it doesn’t appear that the script is working.

I really don’t think this is the mailbox containing the messages that were moved by the AOL server. It doesn’t have access to your On My Mac mailboxes.

This leads me to think that your account is improperly configured in Mail. You should go to the Mailbox Behaviors settings and select as the Junk mailbox the mailbox that contains the spam messages. Then the rescue script will know where to look for them.

If you need further assistance, it would help to see some screenshots showing your mailbox listing Mail and how Mailbox Behaviors is set up.

Actually you brought up an interesting point. “On My Mac” was an inbox that I made after a mishap I had (TLDR: I deleted it, not relevant to anything).

That being said, when I run the Console, then the rules, the 2 AOL accounts in question do NOT appear in the logger, but my other emails do (I have all sorts of different emails).

As for screenshots, I’m not sure what “mailbox listing Mail” is, but I can show my “Mailbox Behaviors”. (It’s the same for both of the AOL accounts)

Where it says All Junk in your screenshot, you should instead select the Junk or Spam mailbox that’s inside of your AOL account. You’ll know when it’s correct because all the spam messages that the server is catching will appear inside the Junk mailbox with the special × icon in Mail’s sidebar.

Okay, I switched them both back to their separate “Junk” folders.

After that I tried the Console, selecting the junk emails and then applying rules.

Although nothing happened, this time I did get a relevant log:

SpamSieve [Apple Mail Rescue Good Messages] Start checking mailbox “HIDINGEMAIL” / “Junk”:

SpamSieve [Apple Mail Rescue Good Messages] Total messages in mailbox “HIDINGEMAIL” / “Junk”: 5 [<<This seems like an improvement as there was 5 junk emails selected.]

SpamSieve [Apple Mail Rescue Good Messages] Error -1743 filtering mailbox “Junk” of account “HIDINGEMAIL”: Not authorized to send Apple events to SpamSieve. [<<I think this is the problem.]

“Not authorized to send Apple events to SpamSieve” sounds like it’s the issue, but I have Mail, Script Editor, Terminal, and SpamSieve Full Disk Access.

And Mail, SpamSieve, Terminal, and Mail are allowed in “Automation” options as well.

I still recommend that you first test using Script Editor. And if you do want to test using Apply Rules, select other messages (e.g. a good message in the inbox), not the ones in Junk.

This errAEEventNotPermitted error means that whatever is running the script doesn’t have Automation access to communicate with SpamSieve. Do you see SpamSieve there unchecked under any apps?

Automation Access if fine (this was what I already had):

With the documentation link provided; I did this command in the terminal: ‘tccutil reset AppleEvents’ an then restarted my Mac.

That “appears” to have done it.

I also did change the script to “True” for pMoveBlueMessagesToTrash, and pMoveGrayMessagesToTrash - running it in Script Editor did move them to the Trash.

I’ve been keeping track, and it appears SpamSieve is now working. (There’s even logs of SpamSieve picking them up)

Great!

Thanks. I should also have asked how the Mail rules should be set up.

  1. The script file needs to be installed in the folder /Users/<username>/Library/Application Scripts/com.apple.mail.
  2. In Mail’s settings, create a rule called Rescue Good Messages SpamSieve. It should be at the top of the list.
  3. The rule conditions should say Every Message.
  4. The rule actions should say Run AppleScript […]Apple Mail - Rescue Good Messages.scpt. First, choose Run AppleScript from the pop-up menu; then select Apple Mail - Rescue Good Messages from the pop-up menu.

Is that the only rule needed? No Remote Training etc.?

The remote training rule is only needed if you want to do remote training (TrainSpam/TrainGood mailboxes). The rescue rule is for processing the messages that the mail server moved to Junk.

If there is a better way to block senders that have already been identified as spam I would love to hear it. I get hundreds of emails a day, may from the same dozen, or so, senders (at least according to ‘sender name’ - I haven’t done analysis on actual email addresses they are from… yet).

Better in what respect? The above method will block them if the sender name is the same.

Just an FYI the “Apply Rules” works and I don’t have to apply it twice for both accounts at least.

It seemed like it was automatic, but isn’t (or isn’t anymore).

No settings were changed and I’m not really complaining, I’m just letting people who see this thread know what’s up.

If you use Apply Rules, it will run the script, which will look in all the Junk mailboxes. The messages that are selected when you choose Apply Rules are irrelevant. That’s why you don’t need to apply it twice.

This is really only intended for testing. Mail should be automatically applying the rules when new messages arrive in your inbox. If you want to run the script at other times (e.g. when there are no new inbox messages but there are new messages in Junk) it’s better to save the script as a standalone app that can run in the background and check for new messages automatically.