How do I know SpamAssassin is working?

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
User avatar
simondsmason
Normal user
Normal user
Posts: 147
Joined: 2007-11-29 00:52

How do I know SpamAssassin is working?

Post by simondsmason » 2008-02-16 21:33

I managed to get it installed - which wasn't easy. I have no errors in the log from the script. I am using SPAM checking built into hMail. I don't see any change in the files coming through. I believe SpamAssassin is supposed to mark spam with ****SPAM**** but I have no idea where the configuration file is to check this - all of the docs refer to unix file locations, nothing for windows users. Anyone have any advice? Thanks.
Simon DS Mason

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2008-02-17 16:28

Check the local.cf config file to see that header rewriting is enabled.

User avatar
dzekas
Senior user
Senior user
Posts: 2486
Joined: 2005-10-13 21:28
Location: Lithuania

Re: How do I know SpamAssassin is working?

Post by dzekas » 2008-02-17 18:32

simondsmason wrote:I managed to get it installed - which wasn't easy. I have no errors in the log from the script. I am using SPAM checking built into hMail. I don't see any change in the files coming through. I believe SpamAssassin is supposed to mark spam with ****SPAM**** but I have no idea where the configuration file is to check this - all of the docs refer to unix file locations, nothing for windows users. Anyone have any advice? Thanks.
Send yourself email with 'XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X' text. Or something similar to sample-spam.txt in your SpamAssassin install.

plobby
Normal user
Normal user
Posts: 115
Joined: 2008-01-29 07:04

Post by plobby » 2008-02-17 21:12

Would you mind letting me know if you found any decent tutorials/guides?

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2008-02-17 22:10

simondsmason, can you explain a little more about your installation? I mean is it a cygwin install, activeperl or is it sawin32? Also, what version of hMail server are you using? It would be easier to help given that information.

User avatar
simondsmason
Normal user
Normal user
Posts: 147
Joined: 2007-11-29 00:52

Post by simondsmason » 2008-02-23 16:10

I am using hMail 4.4.1 273.

I am using Active Perl.

My script in eventhandlers is below:

I sent the test string and it goes through without interruption, so something is not working. I am not positive how to do the settings for SpamAssassin. I guess it is possible that the SPAM is going through but SpamAssassin is not doing anything to it? How do I set it to mark the header with something so I can see if it is working? Thanks for your help.





' Sub OnClientConnect(oClient)
' End Sub

' Sub OnAcceptMessage(oClient, oMessage)
' End Sub

Sub OnDeliverMessage(oMessage)

fname = oMessage.filename

Dim infile, testfile
Dim fso
Set fso = createobject("Scripting.FileSystemObject")
If Not fso.fileexists(fname) then
result.Value = 0
Exit sub
End If

infile = fso.getabsolutepathname(fname)
testfile = infile & ".tmp"
fso.CopyFile infile, testfile

doSpamAssassin = True

'i do some checks here which i removed that can decide to not to the check

If doSpamAssassin Then

'CALL SPAMASSASSIN (modify as required)
Dim cmd, cmd1, rc, rc1, sh
' cmd = "cmd /c c:\spamassassin\spamc.exe -E -s 512000 < """ & testfile & """ > """ & infile & """"
cmd = "cmd /c perl -S -T -w spamassassin -E -s 512000 < """ & testfile & """ > """ & infile & """"

Set sh = CreateObject("WScript.Shell")
rc = sh.Run( cmd , 0 , TRUE)
If rc = 0 Then
'Do something for HAM - if u want to do something when emails are good
ElseIf rc = 1 Then 'Do something for SPAM
'Uncomment next two lines to reject spam .. otherwise it will just change the subject and headers of the email (depending on your spamassasin settings)
' result.Value = 1
' Exit Sub
End If

If fso.GetFile(infile).Size = 0 Then 'Failsafe: In the event an error causes a zero byte msg
fso.CopyFile testfile, infile
End if

fso.Deletefile testfile
Set fso = Nothing
result.value = 0

End If


End Sub

' Sub OnDeliverMessage(oMessage)
' End Sub

' Sub OnBackupFailed(sReason)
' End Sub

' Sub OnBackupCompleted()
' End Sub
Simon DS Mason

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2008-02-23 18:08

I think there is always at least ONE header written by SA. My first thought after looking at your script is that perhaps perl is not in your path. If that's not the problem, perhaps you can sprinkle a few "EventLog.Write"s through your script and see if you can determine where it's breaking down.

User avatar
simondsmason
Normal user
Normal user
Posts: 147
Joined: 2007-11-29 00:52

Post by simondsmason » 2008-02-24 16:46

Thanks for the writelog tip. I did this. perl\bin is in the path. What I found out from the debugging is the following:

It appears that SpamAssassin is running because I am getting an rc value although it is always 64?

Also, the zero byte file test is triggering everytime - so "infile" is testing positive - and this is copying testfile back into infile (resetting the message back to it's original state) - which explains why I see no evidence of SpamAssassin running in the email client.

So, I am assuming that my SpamAssassin Commandline is not working correctly - and it is returning a zero byte email file?

cmd = "cmd /c perl -S -T -w spamassassin -E -s 512000 < """ & testfile & """ > """ & infile & """"

I can't find any good documentation on the commandline for SpamAssassin - I copied this from another script posted to this forum. Any thoughts on the commandline or checking the installation of SpamAssassin?
Simon DS Mason

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2008-02-25 01:23

Sorry I didn't notice this before.... your command line is wrong. It has switches that are only used by spamc. Here is a copy of one I used to use long ago, I'm pretty sure it will work as it is.

Code: Select all

cmd = "cmd /c perl -S -T -w spamassassin < """ & testfile & """ > """ & infile & """"

Hope this helps.

EDIT: The -E switch in spamc generates an exitcode 1 for spam and 0 for ham (or a problem). For SpamAssassin, the -e (lowercase) does kinda the same thing except the value is "non-zero" for spam.

User avatar
simondsmason
Normal user
Normal user
Posts: 147
Joined: 2007-11-29 00:52

Post by simondsmason » 2008-02-25 01:41

Thanks, that did the trick. Should I consider recompiling and using spamc? What are the advantages over what I currently have? Thanks.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2008-02-25 01:50

It's faster, at the expense of running a spamd service all the time. If you don't get much mail it's pretty much the same either way. Buf if you have a lot of users, it will probably be a necessity at some point.

Post Reply