SpamSieve does not have an HTTP API on that port, nor an AllowRemoteControl setting. I’m not sure where you found those…
However, it does have an AppleScript API. You could do something like this:
import subprocess, tempfile, os
# Fill these in with info from your IMAP server
sourceBytes = b""
accountName = "MyAccountName"
mailboxName = "MyMailboxName"
# Message may be larger than the argument or environment limit, and there's seemingly no way to pass to AppleScript via stdin these days, so write a temporary file
fd, path = tempfile.mkstemp(".eml", "MessageForSpamSieve")
with os.fdopen(fd, "wb") as file:
file.write(sourceBytes)
appleScript = """
on run _argv
set {_path, _accountName, _mailboxName} to _argv
-- Read without encoding so the "string" gets passed to SpamSieve without changing the bytes
set _file to open for access _path
set _source to read _file
close access _file
tell application "SpamSieve"
-- Change to true if you will be correcting mistakes, either via another script or SpamSieve’s Log window
set _autoTraining to false
set _origin to {source identifier:"com.yourdomain.imap-script"}
set _origin to _origin & {application name:"YourScriptName"}
set _origin to _origin & {application version:"1.0"}
set _origin to _origin & {mail account type:"IMAP"}
set _origin to _origin & {mail account name:_accountName}
set _origin to _origin & {mailbox name:_mailboxName}
set _score to score message _source auto training _autoTraining origin _origin
return _score
end tell
end run
"""
args = [
"/usr/bin/osascript",
"-e", appleScript,
path,
accountName,
mailboxName
]
completedProcess = subprocess.run(args, capture_output=True)
if completedProcess.returncode == 0:
scoreBytes = completedProcess.stdout
score = int(str(scoreBytes, "utf-8"))
if score >= 50:
print("Message is spam")
else:
print("Message is good")
else:
print("Error:", completedProcess.stderr)
os.remove(path)
When I first bought this I was using new outlook (2 years ago?). I knew that wouldn’t last because new outlook kind of blows. We used spamsieve with apple Mail and let it sync. But I thought emclient was supported. Anyway, I switched to emc because I knew it supported applescript but I am not prepared to do the implementation myself. I have too much on my plate now. Any chance this is in the works? Or am I still stuck with this clunky 2 mail client approach?
OK. Thank you, MIchael. Legacy outlook is doomed and microsoft has turned the editor into fluff. It used to be word and was strong. No more outlook for me after 30 years