XMailforum is a readonly knowledge archive now.

Registering as a new user or answering posts is not possible anymore.

Might the force be with you, to find here what you are looking for.

2019-09-20 - hschneider, Admin

Cookie Disclaimer: This forum uses only essential, anonymous session cookies (xmailforum*), nothing to be scared of.

XMail Forum [Powered by Invision Power Board]
Printable Version of Topic
Click here to view this topic in its original format
XMail Forum > Documentation and Knowledge Base > Spamassassin For Win32 Systems


Posted by: hschneider May 22 2003, 01:59 PM
Thanks for the contrib!

Posted by: petlof May 22 2003, 02:24 PM
Forgot to write that you need to change the two directory pointers in the beginning of sa_filter.pl
One for where you want your log-files and one for where you want to put temp-mail while the filter is working.

so change
my $XMAIL_LOG_PATH="c:\\MailRoot\\filters\\sa\\logs";
my $TMP_DIR="c:\\mailroot\\filters\\sa\\tmp";

So that they correspond to your system.

Posted by: smago Jul 10 2003, 04:42 PM
I try to install Spamassassin on win2k advanced server and I found an "XMSpamAssassinFilterInstaller.msi" file but when I run it
it ask me to install Xmail server or I installed it....

Thx happy.gif

Posted by: hschneider Jul 10 2003, 04:49 PM
Please contact its author. You are the 2nd one with that problem ... If he gets a lots of requests, he might fix it faster ...

Posted by: smago Jul 11 2003, 08:49 AM
Ok I install Spamassassin...
I put this ligne in filters.in.tab : "*"<tab>"*"<tab>"0.0.0.0/0"<tab>"0.0.0.0/0"<tab>"safilter.tab"
I put safilter.tab file in Filters directory
(safilter.tab: "c:\perl\bin\perl.exe c:\Program Files\xmail-1.15\MailRoot\filters\sa\sa_filter.pl" <tab> "-f" <tab> "-r" <tab> "@@RCPT" <tab> "-t" <tab> "@@FILE" )

Spamassassin works if I test it in commmand ligne (Ex : spamassassin -D -t < sample-spam.txt > spam.txt) but when I send a spam mail it do nothink....

Posted by: smago Jul 11 2003, 09:43 AM
I found my a solution :

It a Path problem ... because I have space in Path...
c:\perl\bin\perl.exe c:\Program Files\xmail-1.15\MailRoot\filters\sa\sa_filter.pl --> c:\perl\bin\perl.exe c:\Progra~1\xmail-1.15\MailRoot\filters\sa\sa_filter.pl

Sorry for my stupide question happy.gif

Posted by: hschneider Jul 11 2003, 12:00 PM
Stupid questions don't exist ... BTW: You've found a solution for all nerved SA/Win32 users! Thanks!

Posted by: smago Jul 11 2003, 02:11 PM
I forgot some one in sa_filter.pl change "Program files" to "Progra~1" if you path use program files directory

Ex:
my $XMAIL_LOG_PATH="c:\Program files\xmail-1.15\MailRoot\filters\sa\logs";
my $TMP_DIR="c:\Program files\xmail-1.15\MailRoot\filters\sa\tmp";

repalce by:
my $XMAIL_LOG_PATH="c:\Progra~1\xmail-1.15\MailRoot\filters\sa\logs";
my $TMP_DIR="c:\Progra~1\xmail-1.15\MailRoot\filters\sa\tmp";

Now I have some probleme whitch SA header I don't know why but I have an jump line between Mail header and spam header... conclusion spam header is merge
with message

EX:
mail message send :
hello this is a test !

mail after spamassasin :
Spam-Status: No, hits=0.0 required=5.0
tests=none
version=2.55
X-Spam-Level:
X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)

hello this is a test !

Posted by: smago Jul 16 2003, 09:47 AM
Spamassassin don't work with XMail 1.16 but it work with XMail 1.15. I think it's a Header probleme...

tongue.gif

Posted by: hschneider Jul 16 2003, 09:50 AM
The difference between these version are the filter return codes. They need to be adapted in SA and other scripts.

Posted by: smago Jul 21 2003, 11:29 AM
it's true hschneider, return codes change return code 100 change to 7

if you want to use Spamassassin with Xmail 1.16 you must edit "sa_filter.pl"

Old line :
# We're always modifying the message because spamassassin will add some X-Spam- headers
# if it's spam or not.

exit 100;

new line:
# We're always modifying the message because spamassassin will add some X-Spam- headers
# if it's spam or not.

exit 7;

Posted by: smago Jul 21 2003, 11:36 AM
I modify sa_filter.pl


Posted by: bim Aug 12 2003, 06:57 PM
Hmmm, I just rebooted and now things work mellow.gif

sorry about that one

I'm on to the next problem now however... So if anyone knows why every newline now is turned into a double newline, let me know! rolleyes.gif

Posted by: bim Aug 13 2003, 11:38 AM
I commented out
$checkedEmail=~s/(?<!\r)\n/\r\n/g;
which seems to resolve the double newlines...

Posted by: stealth Sep 11 2003, 02:51 PM
Thanks to this thread I got spamassassin to work on Win2003.
Thanks very much!

But now I want more, but do not no how to get there:
I have spamassassin to mark spam as spam.
I want to move this spam to a sub-directory in the mailbox.
How do I do that?


Posted by: hschneider Sep 11 2003, 05:54 PM
E.g. with a custom script hooked into filters.in.tab. It scans the header for Spam Assasin's tags and, moves the message to the appropriate user's diectory. Then it stops the message's further travel by return code.


Posted by: stealth Sep 12 2003, 08:27 AM
Yes, that is what I figured out myself.
But I haven´t got a clue on how to make such a script.
The readme does not help me with that.

Posted by: hschneider Sep 12 2003, 08:44 AM
You can use any programming language for "scripting". You just need to parse the command line arguments and set the proper return codes.

If you are not used to program, please set your request into the scripting corner here.


Posted by: bim Sep 23 2003, 08:15 PM
Not much of an update, but I like the feature and I guess those who don't know any Perl will appreciate not having to code even this one line of Perl smile.gif:

I want to be able to instantly see which message is spam and which isn't. Changing the subject seemed like the best way to do this. I changed


QUOTE

if ($checkedEmail=~/X-Spam-Flag: YES/) {
$isSpam="SPAM";
#$checkedEmail=~s/(?<!\r)\n/\r\n/g;
$xmailHeader=~s/(?<!\r)\n/\r\n/g;
}

into
QUOTE

if ($checkedEmail=~/X-Spam-Flag: YES/) {
$isSpam="SPAM";
#$checkedEmail=~s/(?<!\r)\n/\r\n/g;
$xmailHeader=~s/(?<!\r)\n/\r\n/g;

#modify subject
$checkedEmail =~ s/\nSubject: /\nSubject: [spam] /i;
}


This way every message that is marked as spam bij SA will have a subject that starts with [spam].

Posted by: whitedaisy Oct 14 2003, 08:58 AM
I am running with Windows 2003. No problems per say yet. I am currently in the process of rewriting the filter provided by Don Drake (thanks!!!) to be more optimized for Windows since we don't have the use of SPAMD and SPAMC yet.

http://www.variummedia.com/OptSpamAssassin.zip

I've attached the optimized filter as well as some performance results I have collected in the past day or two (I'll send them again after a full week) - basically the new filter is running 40% or so faster (so far) - primarily because it uses the SpamAssassin API directly instead of calling out via system(). When system() is called it launches the .BAT file in the perl directory, then it launches perl.exe again. In effect your process tree ends up looking like this (using tlist.exe):

XMail.exe (680)
  perl.exe (1340)
        cmd.exe (744)
            perl.exe (2112)
    perl.exe (964)
        cmd.exe (2144)
            perl.exe (2152)
    perl.exe (2048)
        cmd.exe (2056)
            perl.exe (2120)
... etc

Instead of like this as you would want:
XMail.exe (680)
    perl.exe (1340)
    perl.exe (964)
    perl.exe (2048)

The use of memory was killing my server even though I run with 512 MB of ram. A secondary advantage of using SpamAssassin in this way is you can make different decisions about what to do with spam by using the instance of the status returned by check_message() or check_message_text(). Another interesting option might be to generate domain SpamAssassin prefs on the fly (like turning the threshold down to 5 or something like that), and passing them in via the factory constructor.

Note that I am using an older version of XMail so you will have to adapt the code to the newer return codes. Let me know if there are further ways to optimize this code that you see....we need the assassin to slice faster dry.gif

Posted by: whitedaisy Oct 14 2003, 09:03 AM
QUOTE (bim @ Sep 23 2003, 08:15 PM)
Not much of an update, but I like the feature and I guess those who don't know any Perl will appreciate not having to code even this one line of Perl smile.gif:

I want to be able to instantly see which message is spam and which isn't. Changing the subject seemed like the best way to do this. I changed


QUOTE

if ($checkedEmail=~/X-Spam-Flag: YES/) {
$isSpam="SPAM";
#$checkedEmail=~s/(?<!\r)\n/\r\n/g;
$xmailHeader=~s/(?<!\r)\n/\r\n/g;
}

into
QUOTE

if ($checkedEmail=~/X-Spam-Flag: YES/) {
$isSpam="SPAM";
#$checkedEmail=~s/(?<!\r)\n/\r\n/g;
$xmailHeader=~s/(?<!\r)\n/\r\n/g;

#modify subject
$checkedEmail =~ s/\nSubject: /\nSubject: [spam] /i;
}


This way every message that is marked as spam bij SA will have a subject that starts with [spam].

If I understand what you are trying to do here - it can be accomplished in SA's local.cf by using these two lines:

subject_tag *****SPAM*****
rewrite_subject 1

Posted by: bim Oct 27 2003, 01:42 AM
QUOTE (whitedaisy @ Oct 14 2003, 09:58 AM)
http://www.variummedia.com/OptSpamAssassin.zip

I tried unpacking that zip-file, but got an error message both with WinRAR and the WinXP build-in unzipper that there were no files to unpack. Something wrong with the file?

Posted by: whitedaisy Oct 28 2003, 12:31 AM
I have reposted the zip file - I believe the old one was corrupted for some reason. I have also included a log file with a run using the original sa_filter.pl and the sa_filter_optimize.pl.

I collected stats for over a week of use, the final outcome was an approximate 30% increase in performance instead of 40% as previously reported - still well worth the change.

http://www.variummedia.com/OptSpamAssassin.zip

Let me know if anyone has comments.

Thanks,
-aaron


Posted by: bim Oct 29 2003, 04:55 PM
Thanks!

I hope you don't mind, I've been playing with it myself. If you have any comments, let me know!
http://www.bnamed.net/files/sa_filter_optimize.zip

Important notes:

1. You'll need to install Config::Fast. at the DOS-prompt:
CODE

ppm
install Config::Fast

If you know of a better way to read config files, let me know!

2. I didn't want to check spam on every e-mail address and I want to be able to set-up different ways of working for different accounts. This version will ONLY check mail if the file SAFilter.cf is present in the mail folder (where also user.tab resides). Mails for other accounts aren't checked. This file can be empty, but if you put for example
MinHitsForDelete 10
in it, mails with over 10 hits will be returned to the sender

3. At the start of the script, don't forget to change the paths to both XMailserver and Perl! Also change SA_VERSION_HEADER. This is the complete line from the header that SpamAssassin adds to every e-mail it has checked.

4. Exit codes are for XMailserver 1.16 and above. I only tested with XMailserver 1.17. With this version adding
"*" "*" "0.0.0.0/0" "0.0.0.0/0" "safilter.tab"
to filters.in.tab did the trick, also for e-mail that gets forwarded. I however seem to remember that in 1.16, forwarded e-mail was only filtered with filters.out.tab



Might be interesting if you want to further optimize your own script: I noticed that e-mail that gets forwarded to an other account within the same server is checked twice. So I first check if the SpamAssassin header is present. If it is, the mail isn't checked anymore.

Give it a try an let me know what you think of it!

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)