SpamAssassin Pickup Event not running?
-
- Posts: 11
- Joined: Wed Jan 14, 2004 6:53 pm
SpamAssassin Pickup Event not running?
I am setting up spam filtering on our server and I chose to use SpamAssassin with the ME Pickup Event plug-in. I followed the instructions that were included with the plug-in, but it would seem that the emails are not getting processed by SpamAssassin. I have tested SpamAssassin on the command line and it operates correctly on both the spam and non-spam sample messages. When I send messages that match the spam sample to an account on the server, the message does not get modified and nothing is dropped in the quarentine folder.
Anyone have ideas on ways that I can test the installation to see what my problem could be?
Anyone have ideas on ways that I can test the installation to see what my problem could be?
Spam PickUp Event
Hi, saw your posting (albeit more then a year later) - question - did you ever resolve this as i'm having the same problem?
-
- Posts: 560
- Joined: Mon Nov 03, 2003 7:48 am
- Location: Cape Town
Here is the pick-up event code that I use on my server:
The code is saved in the file MTASpam.vbs. Note that I only process files less than 1MB in size (otherwise processing takes too long) that come from the SMTP connector. Also, I save a copy of all files in the folder C:\Test for manual checking. You might want to get rid of this line (it is commented in the code). The only other thing you would need to check is that the path to the SpamAssassin batch file is correct.
I hope you can get this working as SpamAssassin is a life saver when it comes to spam.
Cheers,
Brett
Code: Select all
'-------------------------------------------------------
' MTASpam.vbs - A pickup event script for MailEnable to run SpamAssassin
'
' USAGE:
'
' 1) Copy the .vbs file to the mailenable\bin directory.
' 2) In the properties of the MTA, enable the pickup event.
' 3) Enter the following in the Program to Execute Field: cscript //T:30 "C:\Program Files\Mail Enable\Bin\MTASpam.vbs"
'
' Note the //T:30 prevents the script from running more than 30 seconds. This will stop a
' confused or looping script from stealing all the CPU from your server!
'
'-------------------------------------------------------
Dim WshShell ' WScript
Dim MailDataPath ' Path of registry values
Dim MessageID ' Message ID of current email
Dim ConnectorCode ' Connection path
Dim MessageFilePath ' Path to original message file
Dim MessageFilePathNew ' Path to processed message file
Dim FSO ' As FileSystemObject
Dim f ' As File
Dim oExec ' As WshScriptExec
Dim cline ' As String
Set WshShell = CreateObject("WScript.Shell")
MailDataPath = WshShell.RegRead("HKLM\SOFTWARE\Mail Enable\Mail Enable\Data Directory")
MessageID = WScript.arguments(0)
ConnectorCode = WScript.arguments(1)
MessageFilePath = MailDataPath & "\Queues\" & ConnectorCode & "\Inbound\Messages\" & MessageID
' Only call SpamAssassin for SMTP events
If ConnectorCode = "SMTP" Then
' Check the size of the mail item
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set f = FSO.GetFile(MessageFilePath)
' Only process files under 1 MB
If f.size <= 1048576 Then
' Set up processed file name
MessageFilePathNew = MessageFilePath & ".tmp"
cline = "C:\Perl\bin\spamassassin.bat -L -e < " & Chr(34) & MessageFilePath & Chr(34) & "> " & Chr(34) & MessageFilePathNew & Chr(34)
Set oExec = WshShell.Exec(cline)
Do While oExec.Status = 0
WScript.Sleep 100
Loop
Set oExec = Nothing
' Check that the processed file actually exists
If FSO.FileExists(MessageFilePathNew) Then
' Copy processed file over original file
FSO.CopyFile MessageFilePathNew, MessageFilePath, true
' For now keep a copy of the processed file
FSO.CopyFile MessageFilePathNew, "C:\Test\", true
' Delete the processed file
FSO.DeleteFile MessageFilePathNew
End If
End If
Set f = Nothing
Set FSO = Nothing
End If
Set WshShell = Nothing
I hope you can get this working as SpamAssassin is a life saver when it comes to spam.
Cheers,
Brett
Spam PickUp Event
Now, I thought all the people who lived by the mountain never worked! Works like a charm! Thankyou. Now to learn how to configure spam assassin!
spamassassin complie strangeness
I followed all of the instructions on: http://www.openhandhome.com/howtosa300.html
and everything was going great until I get to PART IX: Testing SpamAssassin. I run the spamassassin -D -t < sample-nonspam.txt > nospam.txt and get nothing, no debug info in the dos window, nothing in the text output file, but I also get no errors either so I am at a total loss? Does anyone have any idea what the heck is going on?
Jim
and everything was going great until I get to PART IX: Testing SpamAssassin. I run the spamassassin -D -t < sample-nonspam.txt > nospam.txt and get nothing, no debug info in the dos window, nothing in the text output file, but I also get no errors either so I am at a total loss? Does anyone have any idea what the heck is going on?
Jim
-
- Posts: 560
- Joined: Mon Nov 03, 2003 7:48 am
- Location: Cape Town
-
- Posts: 560
- Joined: Mon Nov 03, 2003 7:48 am
- Location: Cape Town
Thanks Brett, your pickup events works great and is much faster then the plug-in from the mail enable site. I only have one lingering problem though and that is some messages are left in the SMTP/incoming/messages folder. Do you know what would cause that or if those will ever be processed? This also occurs if I use the other plug-in.
-
- Posts: 560
- Joined: Mon Nov 03, 2003 7:48 am
- Location: Cape Town
I also find left over messages from time to time but have no idea what would cause that other than real-time virus scanning which in my case is disabled for the whole MailEnable folder array. These messages will never be processed as their header files have gone from SMTP\Incoming and it is only the body that remains in SMTP\Incoming\Messages.
Now that I think about I will have to check whether those messages actually got through or not but, having had no complaints, I would suspect that this is a harmless trait that just requires cleaning the folder of junk every so often. A small price to pay for the power of SpamAssassin !
Now that I think about I will have to check whether those messages actually got through or not but, having had no complaints, I would suspect that this is a harmless trait that just requires cleaning the folder of junk every so often. A small price to pay for the power of SpamAssassin !
mtaplugin.vbs not work
I am a spanish user of ME
I try to use your MTA plugin to spamassassin but it not work.
When i test it, it gives me an error at lines
MessageID = WScript.arguments(0)
ConnectorCode = WScript.arguments(1)
Error Text "The subscript is out of the interval"
can you help me?
I try to use your MTA plugin to spamassassin but it not work.
When i test it, it gives me an error at lines
MessageID = WScript.arguments(0)
ConnectorCode = WScript.arguments(1)
Error Text "The subscript is out of the interval"
can you help me?
Modified
This is Brett's script but modified to Quarantine Email.
Code: Select all
'-------------------------------------------------------
' MTASpam.vbs - A pickup event script for MailEnable to run SpamAssassin
'
' USAGE:
'
' 1) Copy the .vbs file to the mailenable\bin directory.
' 2) In the properties of the MTA, enable the pickup event.
' 3) Enter the following in the Program to Execute Field: cscript //T:30 "C:\Program Files\Mail Enable\Bin\MTASpam.vbs"
'
' Note the //T:30 prevents the script from running more than 30 seconds. This will stop a
' confused or looping script from stealing all the CPU from your server!
'
'-------------------------------------------------------
Dim WshShell ' WScript
Dim MailDataPath ' Path of registry values
Dim MessageID ' Message ID of current email
Dim ConnectorCode ' Connection path
Dim MessageFilePath ' Path to original message file
Dim MessageFilePathNew ' Path to processed message file
Dim MessageJunk 'Quaratnine
Dim MessageJunkMsg 'Quanrantine Msg Folder
Dim FSO ' As FileSystemObject
Dim f ' As File
Dim oExec ' As WshScriptExec
Dim cline ' As String
Dim result 'As Integer
Set WshShell = CreateObject("WScript.Shell")
MailDataPath = WshShell.RegRead("HKLM\SOFTWARE\Mail Enable\Mail Enable\Data Directory")
MessageID = WScript.arguments(0)
ConnectorCode = WScript.arguments(1)
MessageJunk = MailDataPath & "\Quarantine\" & MessageID
MessageJunkMsg = MailDataPath & "\Quarantine\Messages\" & MessageID
MessageFilePath = MailDataPath & "\Queues\" & ConnectorCode & "\Inbound\Messages\" & MessageID
' Only call SpamAssassin for SMTP events
If ConnectorCode = "SMTP" Then
' Check the size of the mail item
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set f = FSO.GetFile(MessageFilePath)
' Only process files under 1 MB
If f.size <= 1048576 Then
'Set up processed file name
MessageFilePathNew = MessageFilePath & ".tmp"
cline = "C:\Perl\bin\spamassassin.bat -e < " & Chr(34) & MessageFilePath & Chr(34) & "> " & Chr(34) & MessageFilePathNew & Chr(34)
'Run SpamAssassin and wait until its finished This is the slowest part of the process
Set oExec = WshShell.Exec(cline)
Do While oExec.Status = 0
WScript.Sleep 100
Loop
Set oExec = Nothing
' Check that the processed file actually exists
If FSO.FileExists(MessageFilePathNew) Then
'Look in the file for the SPAM FLAG
const ForReading = 1
const TristateFalse = 0
dim strMail
dim objFile
dim okjTS
set objFile = FSO.GetFile(MessageFilePathNew)
set objTS = objFile.OpenAsTextStream(ForReading, TristateFalse)
'Specifying the file size will reduce the read time for processing significantly
strMail = objTS.Read(objFile.Size)
If instr(strMail, "X-Spam-Status: Yes") > 0 Then
result = 1
End If
'Release the file from memory so it can be manipulated
set strMail = Nothing
set objFile = Nothing
set objTS = Nothing
Set f = Nothing
If result = 0 Then
' Copy processed file over original file
FSO.CopyFile MessageFilePathNew, MessageFilePath, true
' Delete the processed file
FSO.DeleteFile MessageFilePathNew
Else
FSO.DeleteFile MessageFilePathNew
FSO.CopyFile MessageFilePath, MessageJunkMsg, True
FSO.MoveFile MessageFilePath, MessageJunk
End If
End If
End If
Set FSO = Nothing
End If
Set WshShell = Nothing
-
- Posts: 560
- Joined: Mon Nov 03, 2003 7:48 am
- Location: Cape Town