I use a set of applescripts to help report junk mail to spamcop.

The first script, after sending the raw source of the selected message to spamcop, marks the message as junk and then deletes it.

Later a mail rule sees the spamcop notification, fires of another script which "clicks" the link inside the message, then deletes that message, too.

About an hour later, those deleted messages reappears. The first one is still brown (marked as junk). This behavior has been around since OSX Lion. And it only happens when deleting via applescript.

Has anyone come across this? Is there a way to fix it?

For reference, this is the applescript source. You can check out the full set of scripts at https://github.com/WebVeteran/SpamCop-Deputy

set mySubmissionAddress to "submit.[YOUR ID]@spam.spamcop.net"

tell application "Mail"
    set theMessages to the selection
    repeat with thisMessage in theMessages

        set newMessage to make new outgoing message at end of outgoing messages
        set content of newMessage to (all headers of thisMessage) & (content of thisMessage) as string
        tell newMessage
            set subject to thisMessage's subject
            make new to recipient with properties {address:mySubmissionAddress}
        end tell
        send newMessage
        delay 0.1

        set read status of thisMessage to true
        delay 0.1

        set junk mail status of thisMessage to true
        delay 0.1

        delete thisMessage
        delay 0.1

    end repeat
end tell
  • What mail provider are you using? It's possible the AppleScript delete routine isn't moving it to the actual trash folder for that provider. – tubedogg Aug 24 '16 at 3:19
  • Multiple providers. I have a gmail account with IMAP, also an IMAP account on SmarterMail server. When I manually delete a message, it stays deleted regardless of account. – Jules Aug 24 '16 at 16:27
  • In that case I'd guess whatever the AppleScript routine for delete message is, it's not deleting messages "correctly". Given how long it took them to support the concept of archive versus trash (a la Gmail) I wouldn't be surprised to find out that the AppleScript routine is just broken. I'm not sure why the messages disappear for an hour, though. – tubedogg Aug 27 '16 at 2:23
  • @Jules Did you ever fix this? I'm seeing the same behavior with IMAP accounts: messages deleted from AppleScript reappear next time Mail.app "checks" the IMAP account. Running macOS 10.13 here, but I was seeing this with 10.11 and probably 10.9 as well. – Dale Mar 8 '18 at 17:59
  • I think it many have something to do with other devices also accessing the IMAP account (like an iPhone). The problem has gone away for me. either an update to OSX or iOS might have fixed it. But I can't tell you for sure. – Jules Mar 8 '18 at 18:47

You must log in to answer this question.

Browse other questions tagged .