Junk mail in unknown advertising folder

Dear Michael
On my macbook pro I use OS 11.6 and the Apple mail program: Mail. Junk mail usually ends up in the Spam mailbox, but it also happens occasionally that it ends up in the Unknow advertising folder. I use 6 email addresses and have already installed the “Apple Mail - Server Junk Mailbox.scpt”, but when saving in the script editor I get the error message “Syntax error
Remove line break but found “,”
OK”.
What’s going wrong?
Kind regards Hans

The folder in question is probably from one of your server-side junk filters. Are you able to turn off that feature with your mail host?

Please copy/paste the part that you’re editing, and I’ll help you fix it.

Dear Michael,

I turned of all junk filters in my accounts. Nevertheless it is not solved.

Best reagrds

Hans

The script can handle this for you if you configure it to filter that folder. If you need help with the script, please copy/paste the part that you’re editing, and I’ll help you fix it.

What is the name of the script?

The Apple Mail - Server Junk Mailbox script that you mentioned above.

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