hi,
I've used a quick and excellent guide to setup Spamassassin posted by bazporter here:
http://www.hmailserver.com/forum/viewto ... ight=razor
he also helped me further to set it up, below is a script I ended up with, I've setup 2 email addresses, first is to be intentionally spammed, no legitimate email ever will make it to this email address, second is for forwarding spam emails missed by Spamassassin in this setup as attachments.
Could you guys review it, and possibly I would also like to delete the emails permanently that are going to the 2 accounts, I am still not sure how to do that right...
As far as I can tell it works, however since there is no way to get the success notice out of SA-learn as far as I can tell, I tried the piping I also tried --dump, but without success, perhaps someone with SA-learn experience could show us how to get some feedback to see if learning took place?
I made some changes to capture the Debugging info and now I get this in the log:
Code:
[2192] info: config: failed to parse line, skipping: use_pyzor 0
Does anyone know what that means?
Also, I am hoping for some additional ideas and improvements if any?
Does anyone know of a sure fire way to get spam flowing to the particular email address so we can feed it to SA-learn?
Would be really great to be able to disable Spam protection in hmailserver for those 2 accounts...
Code:
Sub OnDeliverMessage(oMessage)
oMessageSubject = oMessage.Subject
If InStr(oMessageSubject,"[SPAM]") > 0 Then exit Sub 'spam = true
' If InStr(oMessage.To,".files") > 0 Then oMessage.Subject = "[file] " & oMessageSubject :oMessage.Save :exit sub
If oMessage.HeaderValue("X-Spam-Flag") = "YES" Then oMessage.Subject = "[SPAM] " & oMessageSubject :oMessage.Save :exit sub
' Use SpamC (true) or SpamAssassin (false)
const cUseSpamC = true
set oFSO = createObject("Scripting.FileSystemObject")
set oWSO = createObject("WScript.Shell")
' Capture the message filename
sFname = oMessage.filename
' Check if the input file really exists
if not oFSO.FileExists(sFname) Then :Result.Value = 0 :exit sub
oInfile = oFSO.GetAbsolutePathName(sFname) :oTestfile = oInfile & ".tmp" :oFSO.CopyFile oInfile, oTestfile
' Create command strings
cmdSA = "cmd /c C:\SA\spamassassin --configpath=c:\sa\share\spamassassin --siteconfigpath=c:\sa\etc\spamassassin < """ & oTestfile & """ > """ & oInfile & """"
cmdSC = "cmd /c C:\sa\spamc < """ & oTestfile & """ > """ & oInfile & """"
cmdlearn = "cmd /c c:\SA\sa-learn.exe --username=Administrator --spam --sync " & oTestfile' & " >> c:\logs\sa-learnspam2.log 2>&1"
If instr(oMessage.To,"spamme@crm20.com") > 0 Then rcSA = oWSO.Run(cmdlearn , 0 , true) :oFSO.Deletefile oInfile :oFSO.Deletefile oTestfile :Result.Value = 0 :exit Sub
If instr(oMessage.To,"mustbespam@crm20.com") > 0 Then
Set atta = oMessage.Attachments
intCC = oMessage.Attachments.Count - 1
For x = 0 To intCC
Set att = atta.Item(x)
pth = "c:\tmp\" & att.Filename
att.SaveAs( pth )
cmdlearn = "cmd /c c:\SA\sa-learn.exe --username=Administrator --spam --sync --D " & pth & " >> c:\logs\sa-learnspam.log 2>&1"
rcSA = oWSO.Run(cmdlearn , 0 , true)
oFSO.Deletefile pth
Next
exit Sub
End if
if cUseSpamC Then rcSC = oWSO.Run(cmdSC , 0 , true) :else rcSA = oWSO.Run(cmdSA , 0 , true)' use SpamC or Run SpamAssassin
' Failsafe: In the event an error causes a zero byte msg
if oFSO.GetFile(oInfile).Size = 0 Then oFSO.CopyFile oTestfile, oInfile
oFSO.Deletefile oTestfile
Result.Value = 0
set oFSO = nothing
set oWSO = Nothing
end sub