Junk mail in unknown advertising folder

In the attachment I send the part where I have to fill in my accounts of my email addresses. Instead of the email addresses I entered Account 1, Account 2, etc. When running the script I get a Sytax error. How can I fix that?

Naamloos.txt (167 Bytes)

The proper format for 3 accounts is:

on accountAndServerJunkMailboxNames()
    return {{"Account 1", {"Junk"}}, {"Account 2", {"Junk"}}, {"Account 3", {"Junk"}}}
end accountAndServerJunkMailboxNames

But instead of Account 1, etc. you should enter the account descriptions as shown in Mail. And instead of Junk you should enter the name of the advertising folder that you want it to process.

The junk folder is called “Unwanted advertising” in Dutch.
Should Junk in “AndServerJunk Mailbox Names” also be changed to "Ongewenste reclame”?

No, you should only modify the text inside the quotation marks.

I started by entering 3 email accounts and I succeeded. However, when entering another 3 accounts, I kept getting the error message "Syntax error Expected line break but found “,”. After all, I have 6 accounts.
Kind regards
Hans

For 6 accounts you should follow this pattern:

on accountAndServerJunkMailboxNames()
    return {{"Account 1", {"Junk"}}, {"Account 2", {"Junk"}}, {"Account 3", {"Junk"}}, {"Account 4", {"Junk"}}, {"Account 5", {"Junk"}}, {"Account 6", {"Junk"}}}
end accountAndServerJunkMailboxNames

Saving and executing the script was successful. Because the line with accounts was broken in your e-mail of 9/30, I did not see the entire pattern and therefore did not enter the parentheses at the accounts correctly.
Although the execution of the script was successful, this morning junk mail ended up in “Unwanted advertising” again. This also happened after I changed the name Unwanted advertising to Ongewenste eclame.
Regards
Hans

There are two different things to check:

  • Does the script work as desired (empty all “Ongewenste eclame” mailbox completely) when you run it manually?

  • Does Mail run the script automatically when you receive new messages?

After I emptied the Junk folder, messages still appeared in this folder. The only thing that happens when manually executing the script is that I see the result “”. The script does nothing automatically.
I also created another "Apple Mail - server Junk Mailbox 2.scpt and replaced Unwanted advertising with Unwanted advertising. That also doesn’t work.

I recommend that you enable debug logging in the script as described here. Then you can open the Console app, select your Mac under Devices, enter Server Junk Mailbox in the search field, and click Start streaming. Then run the script manually using Script Editor, and you should see some information in Console about what happened.

To make sure that I have performed all actions correctly, I list the steps below:

In Apple Mail - Server Junk Mailbox.scpt I enabled debug logging by changing pEnableDebugLogging from false to true (property pEnableDebugLogging : true)

  1. In Utilities (“hulpprogramma’s”) I Open “Console.app”
  2. I slelect in the Console.app Devices (Apparaten) under Devices MMacbook pro
  3. In the search field I enter “Server Junk Mailbox” and click Start streaming (“Begin met streamen”)
  4. Go to Finder > ibrary (bibliotheek) > com.apple.mail > click on Apple Mail - Server Junk Mailbox.scpt
  5. Run the script (Voer het script uit)
  6. In the console at Info I see a lot of messages
  7. What is the next step?

Kind regards

Hans

After I sent the previous message, I saw in Mail Preferences that a line “Server Junk Mailbox Spamsieve” was also checked. Is that correct?

Schermafbeelding 2021-10-04 om 14.41.30.png.pdf (59.7 KB)

Right after you run the script, please send in an error report.

Yes.

SpamSieve Diagnostic Report.tbz

Thanks. It looks like either the account name or the mailbox name (Unwanted advertising) that you entered in the script does not match the name in Mail, so the script isn’t doing anything because it isn’t finding the right mailbox.

I made a new error report with Unwanted advertising changed to “Ongewenste reclame" in the script. I hope you can find something now.

SpamSieve Diagnostic Report.tbz

A new report, "Spamsive Diagnostic Report 2.tbz I have now created with name changed from Ongewenste reclame to "Reclame”.

SpamSieve Diagnostic Report 2.tbz

It seems like the mailboxes that you specified still don’t match what’s in Mail. You can run this script to see what the actual mailbox names in Mail are.

As an attachment I am sending you the Spamsive Diagnostic report and a partial printout of List Mailboxes.scpt. It does not contain any Junk advertising or ID, but it does contain Trash. I also notice that in the Spamsieve Diagnostic report 2 Accounts mentions Spam. Is that correct?
I have replaced the names of the accounts with Account 1, Account 2, etc.

SpamSieve Diagnostic Report.tbz

Schermafbeelding 2021-10-06 om 13.05.19.png.pdf (52 KB)

Thanks for this information. There seem to be multiple problems:

  1. You have a bunch of account-specific SpamSieve rules in Mail that are disabled, some of which are set to move messages to the inbox. These are unnecessary because you already have a SpamSieve rule at the top that filters every message.

  2. The screenshot from the script says that your accounts have names like Account 1, Account 2, but in the script the account names are entered like e-mail addresses.

  3. The script has some extra { and } for the second and subsequent accounts. (I’ve fixed the example here.)

  4. The mailbox names in the script don’t match the ones in the screenshot.

  5. Did you mean to configure the script to move messages out of Trash?

All of the above is fixable, but you may find it simpler to switch from the Spam mailbox to the Junk mailbox. Then you could have both SpamSieve and the server filters move spam messages to the same place, and you could get rid of the script and all but the single, regular SpamSieve rule. (If you still want SpamSieve to double-check the server filter’s work, there’s a different script for that, which doesn’t require any editing.)