Post new topic Reply to topic  [ 267 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: HOWTO: Using SpamAssassin with hMailServer V4
PostPosted: 2004-12-08 00:37 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Hi there, just incase anyone was wondering how to - here is how to get SpamAssassin (SA) linked to hMailServer (HMS). I guess this would be good if you already have a trained SA database, if not there is ASSP available for use too, or if you want SA in particular.

I havn't tested this for long, but it works ok for me so far.

My system:

PC - Athlon XP 2200+(1.8Ghz), 512MB RAM, 19Gb HDD
Software - Windows 2003 Server Web Edition, IIS 6, hMailServer 3.4 Build 64, ClamAV.080, Perl 5.8.4, SpamAssassin 3.0.1

INSTALLING SPAMASSASSIN
Useful sites:
1.Perl for Windows - SITE
2.Perl for Windows - INSTALLER
3.SpamAssassin.org - SITE
4.SpamAssassin - ZIP DOWNLOAD
5.NMAKE
6.Really good how to install SpamAssassin tutorial

Start by downloading and saving no's 2, 4, and 5 - you will need them for the spamassassin install tutorial (6)

Follow the instructions on link 6. HINTS: type the names of the perl modules exactly as shown, including lowercase and capitals. Ignore from Part X onwards for now, but download the Windows GUI in Part XI, its good. Install everything to the default directories also.

When you have done that, and sucessfully tested SA with the test files if you want to make SA learn to use bayesian testing, you need to train it, or it isn't very effective.

I created a directory (which is shared to my network) on my server with two subs, one called SPAM, the other HAM (EG C:\SALEARN\SPAM). They are for users to copy examples of spam that they recieve that hasn't been marked, and also for examples of regular 'proper' mail so SA can tell the difference. Then i created a batch file on a scheduler to update the database twice a day (to save logging onto the server and doing it manually) The Batch file I use can be downloaded from HERE

Right, so there is perl, spamassassin, and hmailserver is installed? Yes, good.

To get SA to check your mail that passes through the smtp server you have to use the external virusscanner (hMailServer Administrator>settings>smtp>antivirus>external virusscanner) part of HMS to call a window vbs script to pass details around.

Now how SA works is that is is given a file to check, and a destination for the results of the file to go to. To get it to put everything in the right place, use this script HERE and place it in your C drive at the root (C:\) then paste this into the scanner executable field: c:\windows\system32\cscript.exe //nologo c:\sa.vbs
This calls the windows scripting system and tells it to run sa.vbs without showing any splashscreens
And change the Return Value to 55 - otherwise a nutty return value from the script will make HMS think that the file is infected and delete it.

If you want to know about the script and can't find it out yourself, mail me.

Hit the save button to save changes, and then send a test message to yourself to check it works. If you want to see what happens when you get spam, paste the contents of the test spam file you used when checking SA worked earlier and paste into the message of a mail destined for you.

If it is not working and you are getting only blank emails in your inbox, check you have R64 (I know its not marked stable, but its is the only one that works, as it uses long filenames to pass to SA)

If it isnt working, start the log up, and check that the return code is 7 from when you have this line:
"CustomVirusScanner::Scan() - c:\windows\system32\cscript.exe //nologo c:\sa.vbs C:\Program Files\hMailServer\Data\{DBD9394C-D142-415C-AA62-80F3B4C6D60D}.eml - Returned 7"

If it doesn't work, disable the external virusscanner check box and all should return to normal for you. If you are still interested in getting it to work, post back here.


---------------------
ADDED 2nd NOVEMBER 2006

The solution in the first part of this thread is slightly out of date now.

I would recommend that you don't use the external virus scanner option, but the scripts further down the thread instead.


Last edited by john25uk on 2006-11-02 12:50, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-10 11:49 
Normal user

Joined: 2004-12-04 20:57
Posts: 65
Thanks.

I'm busy but part VII doesn't work. When I type 'NMAKE INSTALL' I get the next error:

Quote:
C:\Perl\bin>NMAKE INSTALL

Microsoft (R) Program Maintenance Utility Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

NMAKE : fatal error U1073: don't know how to make 'INSTALL'
Stop.


What's going wrong?


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-10 13:32 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Thats is because you need to be in the spamassassin source directory. Not the PERl\bin folder.

so if you extracted the spamassassin zip to c:\spamassassin then you would need to be in there when you type nmake install.

John


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-10 14:18 
Normal user

Joined: 2004-12-04 20:57
Posts: 65
john25uk wrote:
Thats is because you need to be in the spamassassin source directory. Not the PERl\bin folder.

so if you extracted the spamassassin zip to c:\spamassassin then you would need to be in there when you type nmake install.

John

Okay, but that didn't work!

See:
Quote:
C:\Mail-SpamAssassin-3.0.1>nmake
'nmake' is not recognized as an internal or external command,
operable program or batch file.

How can I make that nmake is recognized as an command?


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-10 14:44 
Developer
Developer

Joined: 2003-11-21 01:09
Posts: 6317
Location: Sweden
You should add C:\Perl\bin\ to the PATH environment setting in the control panel.


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-10 17:26 
Normal user

Joined: 2004-12-04 20:57
Posts: 65
martin wrote:
You should add C:\Perl\bin\ to the PATH environment setting in the control panel.
In Dutch we should said "wablief?" ;)

I don't know what you mean. Control Panel? PATH environment? Please help!! :(


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-11 01:47 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Hi Glenn,

Right, on your desktop, right click the "My Computer" icon and go into the properties.

Then select the ADVANCED tab and click on the "Environmental Variables" button

In the System Variables scroller at the bottom of the window double click the line at had Path in it.

Check to see if it has C:\Perl\bin in it, of not tag it onto the end like so ";C:\Perl\bin" so that there is a ; dividing the entries.

restart your machine and then try the nmake procedures again.

Just on the wild thought, you have extracted the nmake.exe to the perl\bin folder havn't you?

Sorry if I am patronising!

John


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-11 13:24 
Normal user

Joined: 2004-12-04 20:57
Posts: 65
john25uk wrote:
Hi Glenn,

Right, on your desktop, right click the "My Computer" icon and go into the properties.

Then select the ADVANCED tab and click on the "Environmental Variables" button

In the System Variables scroller at the bottom of the window double click the line at had Path in it.

Check to see if it has C:\Perl\bin in it, of not tag it onto the end like so ";C:\Perl\bin" so that there is a ; dividing the entries.

restart your machine and then try the nmake procedures again.

Just on the wild thought, you have extracted the nmake.exe to the perl\bin folder havn't you?

Sorry if I am patronising!

John

Thanks for your information :)
I'll try this tonight.

I have indeed extracted the nmake.exe to the perl\bin folder. That's okay, isn't it?


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-11 14:40 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
yep, thats good.

John


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-12 14:02 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
DOH!!

If you downloaded the vbs script before 12/12/2004 (yesterday) you will need to download it again, as I zipped the wrong, and unworking script. I have fixed it now though, so if it download it now, it will be fine.

John


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-13 12:47 
Normal user

Joined: 2004-12-04 20:57
Posts: 65
So, I've everything installed. Can anyone send me spam at [email protected]?

I've created this account to check SA. Put [email protected] everywhere you can :)


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-13 15:57 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Have you checked that you are getting a 7 as a reply code in your hMailServer logs?

Also have you checked you message headers to make sure that there is the SpamAssassin entry in there? If so can you post a copy of it here please (I am just curious!)

Thanks

John


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-15 13:31 
Normal user

Joined: 2004-12-04 20:57
Posts: 65
john25uk wrote:
Have you checked that you are getting a 7 as a reply code in your hMailServer logs?

No :)
Quote:
Also have you checked you message headers to make sure that there is the SpamAssassin entry in there? If so can you post a copy of it here please (I am just curious!)

Thanks

John

A message header from a spam message:
Quote:
Received: from localhost by jonathan.crediblehosting.nl
with SpamAssassin (version 3.0.1);
Wed, 15 Dec 2004 09:32:42 +0100
From: Penny Hhbuaho <[email protected]>
To: Violet Sdu <[email protected]>
Subject: [SPAM!] commerce bid
Date: Wed, 15 Dec 2004 11:33:08 +0000
Message-Id: <[email protected]>
X-Spam-Flag: YES
X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on
jonathan.crediblehosting.nl
X-Spam-Level: ************
X-Spam-Status: Yes, score=12.8 required=5.0 tests=ALL_TRUSTED,BIZ_TLD,
DATE_IN_FUTURE_03_06,DEAR_SOMETHING,HTML_50_60,HTML_BACKHAIR_8,
HTML_COMMENT_SHORT,HTML_MESSAGE,HTML_OBFUSCATE_50_60,HTTP_77,
HTTP_ESCAPED_HOST,HTTP_EXCESSIVE_ESCAPES,OBFUSCATING_COMMENT,
URIBL_AB_SURBL,URIBL_OB_SURBL,URIBL_SBL,URIBL_SC_SURBL,URIBL_WS_SURBL
autolearn=no version=3.0.1
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_41BFF6AA.777E0000"


Top
 Profile  
 
 Post subject:
PostPosted: 2004-12-15 18:57 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Thats great!

Thanks for posting your headers, I was just being nosey!

If you want to have hmail delete the spam for you, open the vbs file and change the wscript.quit(7) to wscript.quit(rc)

and
add the -e to the cmd string ie:
cmd = "cmd /c perl -S -T -w spamassassin -e < """ & testfile & """ > """ & infile & """"

and set the return code in hMailServer Admin to 5

then it will delete everything that spamassassin thinks is spam.

Though i would get everything marked as spam put into a seperate mailbox instead, so you can check it first before deleting it as you won't know if its really ham

John


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-02 00:41 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
i tried and works; thanks

in new 4.0 HMS, there's the scripting section; do you think is correct simply put your script into EventHandlers.vbs default script?


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-02 01:14 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Yep, defin8ly should be. I am actually gonna do that tomorrow, so will post back then!

Glad it worked!

_________________
C:\ C:\DOS C:\DOS\RUN RUN\DOS\RUN

John 8)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-03 02:12 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
Thanks john25uk, That works really well. I used Spassassin 3.02 and Perl 5.8.6 and had no problems at all. Are you making any progress adding your script to the Eventhandler script? That will be really nice if that works out ok.


Top
 Profile  
 
 Post subject: spamassassin and hmailserver
PostPosted: 2005-03-04 05:27 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
Hi, after tried this spamassassin on ActiveState perl solution here described, i looked for SpamD on Windows (http://wiki.apache.org/spamassassin/SpamdOnWindows) or better, and very cool solution, Spamassassin/spamD on Cygwin (unix emulator) (http://sourceforge.net/docman/display_doc.php?docid=19726&group_id=91728); in this case spamassassin core is loaded once (and not at every mail scanning like SpamAssassin on Perl) and spamd daemon listen on TCP/IP (SA and spamD could stay in the same or in other machine) for a spamC (client) call. WinSpamC (http://sourceforge.net/projects/winspamc/) or also another spamC for win32 (http://software.altaircom.net/software/spamc.aspx), are win32 clients calling spamD for scanning emails for spam, Eg:

WinSpamC < sample-spam.txt > spam-result.txt

and other command line options..

spamC is an executable, so, anyone know how to call from HMailServer an executable passing some parameter, to use this solution for antispam? (Using external virus tab, with a vbs script, including a script in eventhandlers.vbs..etc)


Top
 Profile  
 
 Post subject: Re: spamassassin and hmailserver
PostPosted: 2005-03-04 16:04 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
mirb wrote:
spamC is an executable, so, anyone know how to call from HMailServer an executable passing some parameter, to use this solution for antispam? (Using external virus tab, with a vbs script, including a script in eventhandlers.vbs..etc)


You could probably just modify john25uk's script for that, or stick it in a batch file and run it from the external virusscanner tab.
I couldn't get spamc to work very well, winspamc seems to work but all I can see getting returned is the score. Is that how it is supposed to work? I don't see where the headers would be rewritten. Using spamd from here:
http://wiki.apache.org/spamassassin/SpamdOnWindows
It would be nice if there was spamd that actually ran as a service.


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-04 16:24 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
hi, i tried to modify john25uk's script in many way, and/or create a batch file but.. with no results...

if only score is returned seems to be used -c parameter, look at command line options of winspamc:

-------------------------------------------------------------------------------
WinSpamC.exe [switches] < inputfile [> outputfile]

-a | Max message size, skipped if exceeded. (default=256000)
-c | Just check if the message is spam or not and set exitcode. Will
| print score/threshold to stdout (as ints) or 0/0 upon an error.
-d host | Connect to spamd server on given host. (default=127.0.0.1)
| Supports a list of hosts like: 10.1.1.1,10.1.1.2,10.1.1.3 (no spaces)
-h | Print this help message and terminate without action.
-p port | Connect to spamd server listening on given port. (default=783)
-r | Report only if spam and set exitcode.
-s | Report always and set exitcode.
-t time | Set the timeout in seconds for spamc-to-spamd communications.
| If spamd takes longer than this many seconds to reply to a message,
| spamc will abort the connection, and return exitcode 99.
-u user | Specify the user whose config files spamd should load.
| (default=what Windows says)
-y | Report tests which scored this message and set exitcode.
-$ | Enable debugging mode, output to STDERR.
-$0 | Enable debugging mode, output to STDOUT.
-------------------------------------------------------------------------------
Exitcodes returned are

1 | if message is spam
0 | if not spam
99 | if failure or error occurs.
101 | if message is too large (-a)

-------------------------------------------------------------------------------


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-04 17:00 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
mirb wrote:
hi, i tried to modify john25uk's script in many way, and/or create a batch file but.. with no results...

if only score is returned seems to be used -c parameter, look at command line options of winspamc:


ok... I see now. I was using the -c switch thinking it was needed. I modified john25uk's script, changing only the one line:

cmd = "cmd /c winspamc < """ & testfile & """ > """ & infile & """"

It appears to be working fine... I'll do some more testing with it later.


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-04 18:11 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Cool, Glad you managed to get spamd and spamc working. I havn't looked at it yet as I am up to me ears in another project, but are going to use it soon. Which versions are you using? and where did you get them from (so I can download them too without hunting for them!)

John

_________________
C:\ C:\DOS C:\DOS\RUN RUN\DOS\RUN

John 8)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-04 18:46 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
Hi john, as i already posted:

1):
SA on perl (pure SA on Win32, here SA functions are limited): yuo know already where, is this Topic.
its spamD on win32: http://wiki.apache.org/spamassassin/SpamdOnWindows

2):
SA/SpamD on CygWin (cool solution, SA is completely functional): http://sourceforge.net/docman/display_doc.php?docid=19726&group_id=91728

SpamC client:
WinSpamC: (i think best one) http://sourceforge.net/projects/winspamc/

or another spamc client: http://software.altaircom.net/software/spamc.aspx

in all the net those are the only source i found available..


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-04 18:53 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
john25uk wrote:
Cool, Glad you managed to get spamd and spamc working. I havn't looked at it yet as I am up to me ears in another project, but are going to use it soon. Which versions are you using? and where did you get them from (so I can download them too without hunting for them!)


winspamc I got from here:

http://prdownloads.sourceforge.net/winspamc/WinSpamC-Source-0.5.52.zip?download

and spamd is a modified file from the spamassasin download. Instructions here:

http://wiki.apache.org/spamassassin/SpamdOnWindows

I get a few errors when spamd starts but they don't seem to affect it operation. I think maybe the script needs to be tweaked a bit to prevent that but I don't know enough about perl to do it.


Top
 Profile  
 
 Post subject: spamc RUN!
PostPosted: 2005-03-04 20:21 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
good, good, as GlenC suggested, changing this line in john's script:

cmd = "cmd /c winspamc < """ & testfile & """ > """ & infile &
""""

make spamC running!
- you must already have SA and SpamD started at localhost
- put WinspamC.exe in c:\perl\bin, so the executable is in a system variable PATH, and so it's reachable from any Command Line.

Next step's incorporate this VBS script in Eventhandler.vbs to get Hmailserver automation..


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-04 22:26 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
mirb, your cygwin SA/SPAMD suggestion works pretty well! It was a little pain getting it all set up (but probably not as much as modifying spamd for win32 was). I think I'm going stay with the cygwin setup.


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-05 21:35 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
hello people.

I have adjusted the spamassassin script to use the event scripting system in hMailServer V4.

Here is the code I am using.

Sub OnAcceptMessage(oClient, oMessage)

'get the filename of the message
filename = oMessage.filename

dim infile, outfile
dim fso
set fso = createobject("Scripting.FileSystemObject")
if not fso.fileexists(filename) then
result.value = 0
exit sub
end if

infile = fso.getabsolutepathname(filename)
testfile = infile & ".tmp"
dim cmd, sh, rc
fso.movefile infile, testfile
cmd = "cmd /c perl -S -T -w spamassassin < """ & testfile & """ > """ & infile & """"
set sh = CreateObject("WScript.Shell")
rc = sh.Run( cmd , 0 , TRUE)
fso.deletefile testfile
result.value = 0

End Sub

It seems to work for me. If you don't know how to use scripting in V4 then look in the documents section, it tells you all about it.

Adjust as before for SpamC usage!

_________________
C:\ C:\DOS C:\DOS\RUN RUN\DOS\RUN

John 8)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-06 00:43 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
The script works good, thanks! But have you noticed a considerable delay (about 10 seconds) when it gets handed off to SA? Using winspamc and spamd the delay is more like 1 second.


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-06 02:13 
Developer
Developer

Joined: 2003-11-21 01:09
Posts: 6317
Location: Sweden
Wouldn't it be more wise to use the OnDeliverMessage event? The OnAcceptMessage event occurs synchronizly while the sender is still connected. If you use the OnDeliverMessage, spam assassin will be called after the sender has disconnected when the message is being delivered to the account. This way, the sender can disconnect immediately after the message has been sent.

I think OnAcceptMessage should only be used if there's a chance that the script will not accept the message for delivery. If the script always accepts the message, OnDeliverMessage should be used instead.

Just a sidenote: You do not have to do Result.Value = 0 since 0 is default return value. (But perhaps it's good to have it anyway if it makes reading the code easier)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-06 12:19 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Thanks for the tips Martin, I agree and have changed it already - just not posted back here yet. (I somehow got the accept and deliver order backwards in my head!)

Glen: I havn't noticed a delay on the passover when passing to SA - but are going to change to SpamD today anyway.

_________________
C:\ C:\DOS C:\DOS\RUN RUN\DOS\RUN

John 8)


Top
 Profile  
 
 Post subject: SpamD as a Windows Service
PostPosted: 2005-03-07 02:45 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
A very useful tip: run SpamD as a windows service:

http://www.henry.it/xmail/spamd_windows_service.htm

P.S. if you have SA/spamD on CygWin, make attention about spamd path to use in registry config.: (c:\cygwin\bin\wspamd.bat instead of c:\perl\bin\spamd.bat)

It works, but stopping service all "perl.exe" stay loaded in memory, restarting service a new amount of "perl.exe" are newly loaded (160MB each time on SA on Cygwin and 30Mb on SA on win32); you have to terminate processes manually..


Top
 Profile  
 
 Post subject: SpamD as service on Windows using cygwin
PostPosted: 2005-03-07 23:32 
New user
New user

Joined: 2005-03-07 23:11
Posts: 4
Just thought I would chime in on this topic. This is a great solution thusfar. Can't wait to see this more integrated into hMail.
Anyway, spamd runs great as a service using the cygwin utility cygrunsrv.exe. All perl processes exit properly when the service is stopped.

From the cygwin bash prompt, just run this:

Code:
cygrunsrv -I Spamassassin -p /usr/bin/spamd -a "-c /etc/mail/spamassassin --syslog-socket=UDP"


Of course, the above should be all one line.


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-09 18:24 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
What does "--syslog-socket=UDP" do?


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-09 20:19 
New user
New user

Joined: 2005-03-07 23:11
Posts: 4
By default, spamd tries to use regular UNIX sockets, which fails. I just tried UDP, and it allowed it to run without issue. I was planning to look further into other options there.


Top
 Profile  
 
 Post subject: arguments
PostPosted: 2005-03-09 20:27 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
after spamd service has been created with cygrunsrv, how can i add or delete spamd command line arguments? in your example, -a is the unique spamd argument loaded?


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-09 21:17 
New user
New user

Joined: 2005-03-07 23:11
Posts: 4
GlenC wrote:
What does "--syslog-socket=UDP" do?


After some quick looking into the spamd docs finally, there is a better way to do this.

Code:
cygrunsrv -I Spamassassin -p /usr/bin/spamd -a "-c /etc/mail/spamassassin -s /var/log/spamd.log"


Keep in mind with this that /var/log/spamd.log will need to be rotated or truncated regularly. If rotating, spamd has to be restarted with the rotation.

You would also want to add the following to /etc/mail/spamassassin/local.cf

Code:
bayes_path /etc/mail/spamassassin/bayes
bayes_file_mode 0666


This allows anyone to use sa-learn to train it.


Top
 Profile  
 
 Post subject: Re: arguments
PostPosted: 2005-03-09 21:23 
New user
New user

Joined: 2005-03-07 23:11
Posts: 4
mirb wrote:
after spamd service has been created with cygrunsrv, how can i add or delete spamd command line arguments? in your example, -a is the unique spamd argument loaded?


You have two options. First, and probably easiest:
Code:
cygrunsrv -R Spamassassin

to remove the service, then:
Code:
cygrunsrv -I Spamassassin -p /usr/bin/spamd -a "-c /etc/mail/spamassassin -s /var/log/spamd.log"

and just add your additional spamd options in the quotes after the log setting.

Second option would be to edit the registry. I'll leave that as an exercise for the user. :)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-10 12:02 
Normal user

Joined: 2004-12-04 20:57
Posts: 65
Today I want to use the bayesian spam learning. But, I tried to download your batchfile at http://www.computersurgery.co.uk/hm/updatesa.zip but I got a 404 error. Could you please give me this file? ;)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-10 18:28 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Yep, I don't know when I deleted that, i didn't mean to!

the new link is:
http://www.computersurgery.co.uk/hm/spamlearn.zip

I run it as a scheduled task every 12 hours to save having to run it manually. And my un caught spam and correct ham goes in c:\spamlearn\spam, or /ham, where spamlearn is the shared directory.

I guess its possible to create a script to catch any messages that are sent to a certain mailbox and have them learnt or unlearnt automatically, hmm. I will look at that one day (unless someone else gets there first!)

John

_________________
C:\ C:\DOS C:\DOS\RUN RUN\DOS\RUN

John 8)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-10 19:36 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
I read somewhere that learning from forwarded msgs wasn't good. But I wonder if that is really true? I think that would be the easiest for users to just forward uncaught spam to a spam account and mismarked ham to a ham account and read from there. (That's why I voted for the shared folders in the pending features poll)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-10 19:48 
Normal user

Joined: 2004-12-04 20:57
Posts: 65
GlenC wrote:
I read somewhere that learning from forwarded msgs wasn't good. But I wonder if that is really true? I think that would be the easiest for users to just forward uncaught spam to a spam account and mismarked ham to a ham account and read from there. (That's why I voted for the shared folders in the pending features poll)

You've to put only the attached spam message in your spam or nonspam directory, not the whole forwarded message! :)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-10 20:44 
Normal user

Joined: 2004-12-04 20:57
Posts: 65
Thanks John, it works!


Top
 Profile  
 
 Post subject: chech for spamC
PostPosted: 2005-03-10 21:16 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
If you are running HMail with one of these SA/SpamD/spamC integration solution, and for some reason Spamd stop running, then messages stay in stand by and not delivered; if spamd return to be available messages are processed and delivered as blank massages with not sender, no destinatary and no body; in this case, i think, shoul be helpfull some kind of check in the script like:

check if spamd is available at the host
if spamd is available then
call winspamc
else
don't call winspamc
end if

anyone, have any ideas?


Top
 Profile  
 
 Post subject: Re: chech for spamC
PostPosted: 2005-03-10 22:01 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
mirb wrote:
check if spamd is available at the host
if spamd is available then
call winspamc
else
don't call winspamc
end if

anyone, have any ideas?


That's a good catch... maybe if spamd is not available for some reason it could call SpamAssassin itself instead. At least then it would still get scanned.


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-10 22:47 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
GlenC is right, forwarding messages as spam wound't be a good idea as it wouldn't have the correcting address or anything on it, unless you did it as an attachment and got the script to extract it and then add it? (Thinking while typing there! - wow)

Could possibly test mirb's suggestion that by using the return codes from spamc and spamassassin - if there is one then success, if not then use spamassassin to scan, if no code there, then carry on and allow hMailServer to process the message.

John

_________________
C:\ C:\DOS C:\DOS\RUN RUN\DOS\RUN

John 8)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-11 20:32 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
martin wrote:
Wouldn't it be more wise to use the OnDeliverMessage event?

Martin, Am I correct in assuming that the OnDeliverMessage event is executed on receiving AND sending mail? SpamAssassin is scanning my outgoing mails and that's probably not a good thing. I made need to find another way of doing that.


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-12 17:58 
Developer
Developer

Joined: 2003-11-21 01:09
Posts: 6317
Location: Sweden
Yes, The OnDeliverMessage is executed both on receiving and sending.
It's executed before hMailServer even looks at the recipients and only once for every message. Since one message can have both local and external recipients, the event is executed both for incoming and outgoing.

There's a chart here:
http://www.hmailserver.com/documentatio ... ychart.png

Perhaps it would be a good idéa to add some code that looks on the Message.From property and check whether it's a local sender. If it is, you could simply skip scanning of the file.

(Crap, I'm making dinner and was thinking about this, so instead of focusing on the food I accidently put all the meat in the boiling water instead of in the frying pan.. THANKS for that. ;) )


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-13 02:11 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
martin wrote:
(Crap, I'm making dinner and was thinking about this, so instead of focusing on the food I accidently put all the meat in the boiling water instead of in the frying pan.. THANKS for that. ;) )


(snicker) Sorry about that.. :lol:

Thanks for the chart... that is helpful. I guess I need to learn a little VB now. Doesn't seem this should be too hard to do.


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-13 18:50 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
ok... I'm not really a coder but, I'm giving this my best shot. I'm not doing so well on this script mod. Can someone point me where I'm going wrong here?

Code:
Sub OnDeliverMessage(oMessage)
'get the filename of the message
filename = oMessage.filename

dim infile, testfile
dim fso
set fso = createobject("Scripting.FileSystemObject")
if not fso.fileexists(filename) then
result.value = 0
exit sub
end if

infile = fso.getabsolutepathname(filename)

dim cmd, sh, rc, s1, s2, ts1, ts2
testfile = infile & ".tmp"
fso.copyFile infile, testfile

'Parse the infile here to test for local domain, if true, exit sub
'because we don't need to spam check our own outgoing mail.
dim strLook, locFunction
' error occurs here = Invalid Procedure call or arguement
Set ts1 = fso.OpenTextFile(infile, ForReading)
s1 = ts1.ReadLine()
strLook = "Received: FROM [192.168.1.1]"
locFunction = InStr(1,s1, strLook,1)
if locFunction > 0 then
fso.deleteFile testfile
exit sub
end if


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-16 04:00 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
I've scoured the web and can't seem to find an answer for this. I'm trying to figure a way to identify if the message is local or not. So I'm trying to read the first line and see if it contains my local IP. Anyway... I can't figure out a way to pass the filename in a way that the method wants. Any suggestions appreciated. It's this line that seems to have the problem. I think it is expecting an actual filename and path.

Code:
Set ts1 = fso.OpenTextFile(infile, ForReading)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-16 20:20 
Normal user
User avatar

Joined: 2004-11-30 17:07
Posts: 102
Location: Portsmouth, UK
Hi Glen,

I arn't at my test machine at the moment, but will get you an answer over the weekend.

You should use the the message object that is passed from hmailserver to check the body, I can't remember it off the top of my head but will check it out on Saturday (as far as I can remember)

John

_________________
C:\ C:\DOS C:\DOS\RUN RUN\DOS\RUN

John 8)


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-17 06:12 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
Thanks John, I was able to hack through it tonight and it seems to be working now. I was missing a const statement in there.

I've tested this all of about 10 minutes now but it seems to be working as it should. It checks to see if the file was sent locally (you probably have to modify the SearchString) and it checks to see if spamd is offline (by looking for a zero byte message file). There are probably better ways to do this, and I'd appreciate any feedback to make it work better (or, erm... safer)

Be advised this can REALLY hose up your mail if it doesn't work right :) All applicable safety precautions are advised (i.e backups).

Code:
Sub OnDeliverMessage(oMessage)
'get the filename of the message
filename = oMessage.filename

dim fso
set fso = createobject("Scripting.FileSystemObject")
if not fso.fileexists(filename) then
result.value = 0
exit sub
end if


'Parse the file here to test for local domain, if true, exit sub
'because we don't need to spam check our own outgoing mail.
dim s1, ts1, SearchString
Const ForReading = 1
Set ts1 = fso.OpenTextFile(filename, ForReading)
s1 = ts1.ReadLine
ts1.Close
'For SearchString you must use whatever your machine puts in
'the first line when sending from the local domain
SearchString ="Received: FROM [192.168.1.1]"
If InStr(1, s1, SearchString, 1) > 0 then
Set fso = Nothing
exit sub
end if

dim cmd, infile, testfile
infile = fso.getabsolutepathname(filename)
testfile = infile & ".tmp"
fso.copyFile infile, testfile

'Set timeout for spamd to 15 seconds, and spamc to return error code
cmd = "cmd /c winspamc -t 15 -x < """ & testfile & """ > """ & infile & """"

dim sh, rc
set sh = CreateObject("WScript.Shell")
rc = sh.Run( cmd , 0 , TRUE)

'If spamd failed, infile becomes a 0 byte file, this tests for that
'and if true replaces infile with testfile which is still a good copy
If fso.GetFile(infile).Size = 0 Then
fso.CopyFile testfile, infile
end if

fso.deletefile testfile
Set fso = Nothing
result.value = 0
End Sub


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-17 20:41 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
good, GlenC, your script works fine on my system.

what -x switch daes?


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-17 22:38 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
Actually -x does nothing for winspamc, for spamc it tells it to return error codes. I was assuming WinSpamc used the same switches and return codes which it does not... so I've changed things a little :) Here's a little better version that actually looks at the return codes to determine what to do. If you uncomment the "MsgBox" lines, you can test it with various types of mails (kinda useless for now but maybe in the future you might want to take some other action based on the different codes). Again... same disclaimer as before.
Code:
Sub OnDeliverMessage(oMessage)
'get the filename of the message
filename = oMessage.filename

dim fso
set fso = createobject("Scripting.FileSystemObject")
if not fso.fileexists(filename) then
result.value = 0
exit sub
end if

'Parse the file here to test for local domain, if true, exit sub
'because we don't need to spam check our own outgoing mail.
dim s1, ts1, SearchString
Const ForReading = 1
Set ts1 = fso.OpenTextFile(filename, ForReading)
s1 = ts1.ReadLine
ts1.Close
'For SearchString you must use whatever your machine puts in
'the first line when sending from the local domain
SearchString ="Received: FROM [192.168.1.1]"
If InStr(1, s1, SearchString, 1) > 0 then
Set fso = Nothing
'MsgBox "Message from local domain",0,"Local Domain Check"
exit sub
end if

dim cmd, infile, testfile
infile = fso.getabsolutepathname(filename)
testfile = infile & ".tmp"
fso.copyFile infile, testfile

'Set timeout for spamd to 15 seconds
cmd = "cmd /c winspamc -t 15 < """ & testfile & """ > """ & infile & """"

dim sh, rc
On Error Resume Next
set sh = CreateObject("WScript.Shell")
rc = sh.Run( cmd , 0 , TRUE)

If rc = 0 Then
'   MsgBox "Message is Probably HAM",0,"Woohoo HAM!"
Elseif rc = 1 Then
'   MsgBox "Message is probably SPAM",0,"BOOO, SPAM!"
Elseif rc = 99 Then
'   MsgBox "Error 99, Undefined WinSpamC error, ensure SpamD is running",0,"WinSpamC Error"
   fso.CopyFile testfile, infile
Elseif rc = 101 Then
'   MsgBox "Message skipped by SpamD, Message is too large, > 256kb",0,"WinSpamC Error"
   fso.CopyFile testfile, infile
Else
'   MsgBox "WinSpamC returned an unknown error code",0,"WinSpamC Error"
   fso.CopyFile testfile, infile
End If

'Failsafe: if the above tests don't catch the failure of SpamD, this runs
'If spamd failed, infile becomes a 0 byte file, this tests for that
'and if true replaces infile with testfile which is still a good copy.
If fso.GetFile(infile).Size = 0 Then
'   MsgBox "Ran Failsafe Commands",0,"Check hMail VB Script"
   fso.CopyFile testfile, infile
end if

fso.deletefile testfile
Set fso = Nothing
Err.Clear
result.value = 0
'Msgbox "I ran to here",0, "End of Script"
End Sub


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-18 05:31 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
ok, oneeeeeeeeee more small change... replace the parts of the code from:
"If rc = 0" until the first "End If" with this, and it will call SpamAssassin in the event SpamD doesn't answer for some reason.
Code:
dim cmd1, rc1
If rc = 0 Then
'   MsgBox "Message is Probably HAM",0,"Woohoo HAM!"
Elseif rc = 1 Then
'   MsgBox "Message is probably SPAM",0,"BOOO, SPAM!"
Elseif rc = 99 Then
'   MsgBox "Error 99, Undefined WinSpamC error, ensure SpamD is running",0,"WinSpamC Error"
   cmd1 = "cmd /c perl -S -T -w spamassassin < """ & testfile & """ > """ & infile & """"
   rc1 = sh.Run( cmd1 , 0 , TRUE)
Elseif rc = 101 Then
'   MsgBox "Message skipped by SpamD, Message is too large, > 256kb",0,"WinSpamC Error"
   fso.CopyFile testfile, infile
Else
'   MsgBox "WinSpamC returned an unknown error code",0,"WinSpamC Error"
   fso.CopyFile testfile, infile
End If


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-20 21:42 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
Anyone ever had any luck making this plugin work in SpamAssassin?

http://wiki.apache.org/spamassassin/ClamAVPlugin

Looks interesting, but I can't seem to get it to load, keep getting an error in the spamd.log saying:
"failed to create instance of plugin Mail::SpamAssassin::Plugin::clamav: Can't locate object method "new" via package "Mail::SpamAssassin::Plugin::clamav" at (eval 14) line 1."


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-20 22:51 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
i tried to install it, but it seems to be created only for UNIX like OS and not for win32 even with Cygwin; may i'm wrong..


Top
 Profile  
 
 Post subject:
PostPosted: 2005-03-26 19:12 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
I discovered today that for some reason, when using winspamc, some msgs with attachements were being truncated. In particular I noticed this behavior on JPG and GIF files but it may be happening with other types of attachments too. The spamc.exe that comes with SA does not seem to cause this problem. If you're using winspamc you might want to check for this.


Top
 Profile  
 
 Post subject: User Preferences instead local.cf
PostPosted: 2005-03-29 02:21 
Normal user
User avatar

Joined: 2005-02-28 03:01
Posts: 45
Location: Italy
GlenC: tried every attachment extensions and all is fine on my system.

I tested a new feature, and it's great: filtering email for spam through SpamAssassin with User Pref instead of global pref (in local.cf); 3 good reasons:
- changes in user pref do not need spamd restart to go on-line,
- you can set personalized pref for each email account in Hms,
- preferences can be changed on the fly via web interface

I tested on: Windows 2k3, IIS6, MySQL 4.0.16, hMS 4-91b, SquirrelMail for hMS, SpamAssassin 3.0.3 on CygWin 1.5.12, SpamD as Service (purplebear method), and WinSpamC (GlenC and john25uk modified EventHnadler)
Resourse:
http://spamassassin.apache.org/dist/sql/README

First, create a DB in MySQL (for example spamassassin), and a table:
-------------------- start SQL ---------------------------------
CREATE TABLE userpref (
username varchar(100) NOT NULL,
preference varchar(30) NOT NULL,
value varchar(255) NOT NULL,
prefid int(11) NOT NULL auto_increment,
PRIMARY KEY (prefid),
INDEX (username)
) TYPE=MyISAM;
-------------------------- end SQL---------------------------

add some user pref value in DB, for example:
Image

Now you need DBI and DBD::mysql on CygWin:
for DBI enter CygWin prompt and type:
cpan [enter]
install DBI [enter]

for DBD::mysql isn't so easy, follow instructions at:
http://www.enstimac.fr/Perl/perl5.6.1/site_perl/5.6.1/sun4-solaris/DBD/mysql/INSTALL.html#windows/cygwin

in local.cf, typically in C:\cygwin\etc\mail\spamassassin\local.cf, edit or just add these lines:
----------------------- start local.cf settings -------------------------
# SQL - used only with SPAMD, not with standard SpamAssassin
user_scores_dsn dbi:mysql:DBname:Host_IP_of_MySQL
user_scores_sql_username mysql_username
user_scores_sql_password mysql_password
------------------------ end local.cf settings -------------------------
here change "DBname" with the DB you created beginning this procedure
"Host_IP_of_MySQL" with the IP of MySQL host
and username and password with read/write access to the DB
P.S. remember to include 2 TAB between each name and value

add -u [email protected] (put the same you inserted in username field in DB) to WinSpamC calling line in eventhandler script:
cmd = "cmd /c winspamc -t 15 -u [email protected] < """ & testfile & """ > """ & infile & """"

add -x -q switches to SpamD service and restart it

and all is DONE!!

to change preferences i tested all web user interfeces at:
http://wiki.apache.org/spamassassin/WebUserInterfaces
and at:
http://www.squirrelmail.org/plugins_category.php?category_id=3

the only one, and pretty good, i was able to run is:
http://www.aub.dk/~misak/index.php?cat=6
changing some code parts..


Now, is possible to modify eventhadler script to do this job?:
- get, for each email accepted, hms email destination address
- pass this address to winspamc calling line to call right user pref for the user account

Ciao.


Top
 Profile  
 
 Post subject: Re: User Preferences instead local.cf
PostPosted: 2005-03-29 05:36 
Senior user
Senior user

Joined: 2004-08-17 23:31
Posts: 680
Location: Santiago, Chile
That's pretty cool... when I get some time I think I'll work on setting this up. You can use the MySQL that comes packaged with hMail?

mirb wrote:
Now, is possible to modify eventhadler script to do this job?:
- get, for each email accepted, hms email destination address
- pass this address to winspamc calling line to call right user pref for the user account
Ciao.


For this, I think you can reuse the ReadLine and Searchstring parts already in the eventhandler script to find the recipient... I'm not sure what you would match against though, maybe Martin has a suggestion on that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 267 posts ]  Go to page 1, 2, 3, 4, 5  Next


Who is online

Users browsing this forum: No registered users and 4 guests



Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group