Messages Not Removed from TrainGood

The Spam Filtering Drone is not removing the TrainGood label from messages. The downloaded script file seems to have an error in it. So when a message is put into TrainGood after it processes the message now appears in both INBOX and TrainGood. Then everytime it is run it reprocesses the same message. Looking at the script file I noticed the following line:
my moveMessage(_message, my inboxForAccount(_account), false )
I edited that line and changed the “false” to “true” and now the messages are removed from the TrainGood folder as they should be.

1 Like

Is this with a Gmail account? The script was written that way in order to work around a problem other customers had reported where Mail was not properly moving messages to the inbox. However, if it works better for you with that change, feel free to keep using the script like that.

Yes this is with Gmail. I will have to try my bellsouth and icloud accounts and see what they do.

Ok yes this is causing an issue with my Yahoo mail account. iCloud account works fine.

What happens with the Yahoo account?

Now it is really not functioning correctly. I erased the edited file and redownload a fresh copy and put it in the scirpts folder. I set the flag for logging and the movemessage flag to true. saved the file. But now when I put anything in the traingood folder and run the script it moves the message to Junk. This is happpening on all the accounts but the Mail app no longer freezes.
tell current application

do shell script “/usr/bin/logger -s ‘SpamSieve [Apple Mail Remote Training MJTLog] Moving message to Junk: [C-Command] [SpamSieve] Messages Not Removed from TrainGood’”

→ “”

end tell

tell application “Mail”

move message id 1161014 of mailbox “[Gmail]/All Mail” of account id “CA8C41D2-74E1-4CB2-95C3-D002F332A204” to junk mailbox

The modification that you made was to tell the script that the messages being moved were always spam. If you want to modify the script to tell Mail a different way of moving the messages, I would instead change the line:

move _message to inbox

to:

set _message's mailbox to _mailbox

I don’t understand your point about Mail no longer freezing, since you didn’t mention that before…

Not sure what was happening but the mail app was freezing. It is not anymore. Also, to make Gmail work like the rest with the default script no changes. I went into the Gmail settings itself and turned off “Show in IMAP” Important, Chats, and All Mail. Doing that fixed the issue with Apple Scripts and Gmail IMAP not playing nicely.

1 Like

I’m having the same issue here with SS 3.0.3 and Mail 16.0 on mac OS 14.2.1 (23C71). It seems to only be a problem with my two Gmail accounts, as iCloud moves the messages. As far as I can tell, it seems the logic when using this script is that:

  1. Message is identified as spam and put into the Junk folder (which shows “Spam” label in GMail web UI).
  2. I move the message to TrainGood in Mail, which removes “Spam” and adds the “TrainGood” label in the web UI.
  3. The script runs and moves the message, but actually only adds the “Inbox” label to the message. Now locally the message appears in both folders and in the web UI it has two labels, both “TrainGood” and “Inbox”

It would seem the solution is to remove the TrainGood label when moving the message. I set pMoveBySettingMailbox to false with no change, as well as modified the

move _message to inbox

line with no success. I also don’t see any “Show in IMAP” settings in Gmail as mentioned above. I’ll admit I’ve reached the limit of my knowledge and would appreciate any additional ideas on next steps.

Apple Mail doesn’t offer direct control over Gmail labels, but it’s supposed to remove TrainGood when moving the message to the inbox. I’m not sure why that’s working for other people but not on your Mac.

There’s info about the Gmail IMAP settings here.

Hi @Michael_Tsai ! This is happening to me with my GMail accounts too. Messages moved to TrainGood never have that label removed. Do I need to mod the script as described above? Thanks.

What is the date at the top of your copy of the script?

– Apple Mail - Remote Training

Apple Mail - Remote Training - SpamSieve AppleScripts

– Summary: Training script for setting up a spam filtering drone with Apple Mail.

– Requires: SpamSieve, Apple Mail

– Install Location: ~/Library/Application Scripts/com.apple.mail or ~/Library/Scripts/Applications/Mail/

– Last Modified: 2022-12-27

@Michael_Tsai I re-examined my setup and ran the Remote Training script and ran into the problem again where it didn’t automatically pull my Account Names. I modded the script to input the 3 account names and it worked fine. I’m guessing the script was failing without my realizing since it had worked before. As to why, your guess is as good as mine. I redownloaded the Remote Training Script and tested it. I still had to mod the script to include the account names.

The Recover Good Messages script works fine without any mods.

Maybe I’m missing something? Thanks.

Which mailbox is set as the Junk mailbox in Mail’s Settings ‣ Accounts ‣ Mailbox Behaviors?

You only have to edit the script to add your account names if you don’t have SpamSieve set to use the Junk mailbox for training.

That looks correct. Does it help if you change the line:

property pMoveBySettingMailbox : true

at the top of the script to:

property pMoveBySettingMailbox : false

?

Hi, Michael. It doesn’t seem to matter. See below.

tell application “SpamSieve”

lookup single key “AppleMailUseJunkMailbox” without default value

false

end tell

tell application “Mail”

get account “Account 1”

error number -1728 from account “Account 1”

Result:

error “Mail got an error: Can’t get account "Account 1".” number -1728 from account “Account 1”

Like I said, you either need to set SpamSieve to use the Junk mailbox for training or edit the script to add your account names.

Ugh. I’m a moron. I had it set to Trash instead of Junk. Didn’t remember doing that. Thanks for your patience.