HOW TO: Install Spamassassin For Windows and SPAMD service

This section contains user-submitted tutorials.
Post Reply
User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2015-04-27 11:13

This tutorial is a re-publish of a tutorial already on this forum, but simplified for clarity). It's aim is to install Spamassassin and its service for running in connection with the default integration with Hmailserver.

It is a simple procedure that should only take 5 minutes.

1, Download SpamassassinForWindows from Jam Software here: http://www.jam-software.com/spamassassin/index.shtml

2, Run the install of this software: I will assume defaults for all installation locations for this tutorial.
NOTE: You may need to switch off your firewall during this install so that it can auto update to latest spam rules during install. It will then create some firewall rules for you. Then switch firewall back on. If it has not added such exceptions itself as necessary, add the following programs (from the Spamassassin program directory) to the Firewall Exceptions (for PRIVATE network only). Failure to allow this program exception will result in failed updates (a) and service connection by Hmailserver (b):-
  • a) SA-UPDATE.EXE
    b) SPAMD.EXE
3, Download 'NSSM Service Manager' (service installer) from: http://nssm.cc/download/?page=download
and save the unzipped folder to a disk location where you will run it from permanently (perhaps within program files directory if you wish).

! DO NOT MOVE THE NSSM PROGRAM FROM THIS LOCATION ONCE INSTALLED AS ITS AVAILABILITY IS REQUIRED FOR THE RESULTANT SERVICE TO RUN !

4, Within CMD prompt, CD to the "win64" directory of NSSM location (although they do claim that running win32 version on 64bit OS should still be ok):

5, Install the spamassassin service with this command:
nssm install

and using the onscreen prompts enter (copy) the following:

Version 2.15 (without GUI):
application/path: %ProgramFiles%\jam software\spamassassin for windows\spamd.exe <---- your spamassassin program with full path
options/arguments: -l -s "c:\path to\spamd.log" --round-robin --timeout-child=85 <---change the log path to wherever you wish to locate it **
service name: spamassassin <<----- However you want the service to be identified as.
Example with GUI (Version 2.24):
Untitled.png
(You may choose to write something meaningful in the 'Description' on the DETAILS tab for displaying in the Windows Services control panel.)

Hint: I chose the Hmailserver Log directory ("%ProgramFiles(x86)%\hMailServer\Logs") as a consolidated logs directory so I specified it as the store for my Spamd.log file (c:\path to\spamd.log above).

6, You may wish to modify the 'spamassassin' service via services.msc and set the Recovery options to “Restart the service” for the 1st 2 recovery
failures - although I have not yet found it ever fails (not that I would know - I have it to restart if it does. :roll: )

7, HMS should now be enabled to use Spamassassin: hmailserver / settings / Anti Spam / SpamAssassin Tab - and tick/enable. The default port should be left at 783.

That's it.

Additional Info/advice

Spamassassin requires definition updates (almost daily) just like an AV software. This is achieved by running the following command:

Code: Select all

net stop spamassassin
sa-update.exe -v --nogpg --channelfile UpdateChannels.txt
net start spamassassin
You should include this command daily either by your regular housekeeping backup script or by Task Scheduler not forgetting to refer to the correct path.

** UPDATE: It has also been claimed that the "--round-robin" parameter is no longer needed and actually best to be left out to ensure trouble free and optimal operation in 3.4 onwards. However, with its inclusion I see no error or obvious drawback.

You may now choose how to use the Spamassassin scores. In Hmailserver you have the option to 'Use score from Spamassassin' (in the Spamassassin tab) or to simply assign a positive SA result a particular score of your own. There is no right or wrong, just personal preference. (My personal setup follows this post....)
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2015-04-27 11:35

My recommendation of implementing and handling scores

Here I detail MY implemented scoring method. I find it is very effective as I rarely receive genuine spam emails that has not been removed or identified as [spam] and moved to trash. It is a slightly 'alternative' method but for me it works.

1, I use the default Spamassassin update definitions. In addition, add/ensure this is in your LOCAL.CF (found in %ProgramFiles(x86)%\JAM Software\SpamAssassin for Windows\etc\spamassassin):

Code: Select all

report_safe 0
add_header all Report _REPORT_ *
score DRUGS_ERECTILE 10

# Add *****SPAM***** to the Subject header of spam e-mails
#
rewrite_header Subject [_HITS_]

# Set the threshold at which a message is considered spam (default: 5.0)
#
required_score 3.0
2, Set a GLOBAL RULE:

Name: "ExternalScore7"
if:
X-Spam-Level (custom header) ...contains..... *******
<<-- 7 asterix
action:
Move to IMAP Folder...... Trash
(or whatever your normal trash folder is on your accounts (you may choose a dedicated 'Spam' folder instead). Alternatively you can simply 'DELETE EMAIL' but that never gives you chance to review.)

Note: I also have an additional IF clause as
OR
Subject REGULAR EXPRESSION (?i:^Virus found:.*$)


this works to also remove any emails being found to contain malware by the inbound Antivirus check.

3, Anti Spam settings in HMS:

Code: Select all

ANTISPAM

GENERAL                              SPAM TESTS              Score   SPAMASSASSIN
  Spam Mark:                  5       Use SPF:            True - 3    Use Spamassassin:    True
  Add X-HmailServer-Spam:     True    Check HELO host:    True - 2    Hostname:       127.0.0.1
  Add X-HmailServer-Reason:   True    Check MX records:   True - 2    Port:                 783
  Add X-HmailServer-Subject:  True    Verify DKIM:       False - 5    Use SA score: False -   5
              Subject Text: "[SPAM]"
  Spam delete threshold: 8         Maximum message size: 2048

GREYLISTING:
  Greylisting:  False

DNSBL ENTRIES:
                  zen.spamhaus.org      Score: 5     Result: 127.0.0.2-8|127.0.0.10-11
                    bl.spamcop.net      Score: 3     Result: 127.0.0.2
            b.barracudacentral.org      Score: 2     Result: 127.0.0.2
     hostkarma.junkemailfilter.com      Score: 2     Result: 127.0.0.2|127.0.0.4
           bl.spameatingmonkey.net      Score: 2     Result: 127.0.0.2-3
                   cbl.abuseat.org      Score: 2     Result: 127.0.0.2

SURBL ENTRIES:
                   multi.surbl.org      Score: 3
-----------------------------------------------------------------------------------------------
Generated by HMSSettingsDiagnostics v1.48, Hmailserver Forum.


IN ADDITION TO using Spamassassin and the above scoring system, I also operate a DISPOSABLE ADDRESS system to minimise the risk of 'real' account addresses getting in the hands of unwanted spamming lists; should an address given ends up being abused it is simply blacklisted and emails will never be received to that address again (and no setting up of the email addresses is required). This keeps the real account Inboxes clean and the reliance on Spamassassin at a minimum. You can implement it using this script: viewtopic.php?f=20&t=29306

For explanation (of this alternative method):

It works like this: if spamassassin scores over 3 it will consider it spam and apply the score in the subject eg "[3.4]..". HMS will also see SA has called it spam and therefore will mark it spam (scoring it internally as '5') with an additional "[SPAM]" eg so subject now reads "[SPAM] [3.4]..." This helps you see the score and how definitive it is. See the attached screenshot:
Untitled.png
HMS will then apply its own further checks. If it finds any itself another (minimum of) 2 will be added internally (making 7). If it hits 8 with its tests it will simply be deleted without a trace.

If, however, HMS doesnt score it any more, and it's only SA that marked it and if SA scored it 7 or more it will simply be deleted/moved to Trash/Spam folder to give you chance to see it. (The above included screenshot is from the Trash folder and shows such cases).

If it was marked as Spam by SA but did not reach either SA 7 or HMS 8 it will remain in your mail just marked as spam ("[SPAM] [4.5] Subject....") and requiring review. I RARELY get this situation.

In essence I get a clean sheet or mostly positive spams being deleted and the inbox remains clean.

NOTE:

If you have or are regularly receiving Apple, Paypal, iTunes or Amazon Account "reset your account" phishing emails, or regular "Buy your Louis Vuitton handbags" or "Rayban Sunglasses", I also have a an effective custom rule that eliminates them too - just let me know.

This completes my total Spamassassin/Spam scoring setup. It works for me! Feel free to use it as suggestion, hint or 'what not to do' (if thats the way you feel.) :-)

For reference:

Code: Select all

28/03/2017 09:38:46   Hmailserver: 5.6.6-B2383

IP: 127.0.0.1 - 127.0.0.1     Priority: 15     Name: My computer

  Allow connections                         Other
     SMTP:   True                              Antispam :   True
     POP3:  False                              Antivirus:   True
     IMAP:   True                              SSL/TLS:    False

  Allow Deliveries from                     Require Authentication from
     Local To Local       -  True              Local To Local       - False
     Local To External    -  True              Local To External    - False
     External To Local    - False           
     External To External - False           


IP: 0.0.0.0 - 255.255.255.255     Priority: 10     Name: Internet

  Allow connections                         Other
     SMTP:   True                              Antispam :   True
     POP3:  False                              Antivirus:   True
     IMAP:   True                              SSL/TLS:    False

  Allow Deliveries from                     Require Authentication from
     Local To Local       -  True              Local To Local       -  True
     Local To External    -  True              Local To External    -  True
     External To Local    -  True              External To Local    - False
     External To External - False           


------------------------------------------------------
AUTOBANNED Local Addresses:
    No entries

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

AUTOBAN
  Autoban Enabled: True       Max invalid logon attempts:      2
                              Minutes Before Reset:         1500  (25.00 hours, 1.04 days)
                              Minutes to Autoban:          10140  (169.00 hours, 7.04 days)

There is a total of 3 auto-ban IP ranges.
-----------------------------------------------------------------------------------------------

INCOMING RELAYS
    No entries

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

ANTISPAM

GENERAL                              SPAM TESTS              Score   SPAMASSASSIN
  Spam Mark:                  5       Use SPF:            True - 3    Use Spamassassin:    True
  Add X-HmailServer-Spam:     True    Check HELO host:    True - 2    Hostname:       127.0.0.1
  Add X-HmailServer-Reason:   True    Check MX records:   True - 2    Port:                 783
  Add X-HmailServer-Subject:  True    Verify DKIM:       False - 5    Use SA score: False -   5
              Subject Text: "[SPAM]"
  Spam delete threshold: 8         Maximum message size: 2048

GREYLISTING:
  Greylisting:  False

DNSBL ENTRIES:
                  zen.spamhaus.org      Score: 5     Result: 127.0.0.2-8|127.0.0.10-11
                    bl.spamcop.net      Score: 3     Result: 127.0.0.2
              zz.countries.nerd.dk      Score: 5     Result: 127.0.0.158|127.0.2.131|127.0.2.198
            b.barracudacentral.org      Score: 2     Result: 127.0.0.2
     hostkarma.junkemailfilter.com      Score: 2     Result: 127.0.0.2|127.0.0.4
           bl.spameatingmonkey.net      Score: 2     Result: 127.0.0.2-3
                   cbl.abuseat.org      Score: 2     Result: 127.0.0.2

SURBL ENTRIES:
                   multi.surbl.org      Score: 3
-----------------------------------------------------------------------------------------------

WHITELISTING
    No entries
-----------------------------------------------------------------------------------------------

ANTIVIRUS

GENERAL:
  When found - Delete Attachments.

  Max Message Size: 26214
     CLAM AV:   True       Hostname: localhost    Port: 3310
     CLAMWIN:   False
     CUSTOMAV:  False

  Block Attachments: True
               *.7z              
               *.bat             Batch processing file
               *.cmd             Command file for Windows NT
               *.com             Command
               *.cpl             Windows Control Panel extension
               *.csh             CSH script
               *.docm            Macro enabled Office
               *.dotm            Macro enabled Office
               *.exe             Executable file
               *.inf             Setup file
               *.lnk             Windows link file
               *.msg             .msg message files
               *.msi             Windows Installer file
               *.msp             Windows Installer patch
               *.pif             
               *.reg             Registration key
               *.scf             Windows Explorer command
               *.scr             Windows Screen saver
               *.vbs             
               *.xlsm            Macro enabled Office
               *.xltm            Macro enabled Office
               *.zip             
               .js               JavaScript
-----------------------------------------------------------------------------------------------

SSL/TLS
             SSL 3.0 :  False
             TLS 1.0 :  False
             TLS 1.1 :   True
             TLS 1.2 :   True                Verify Remote SSL/TLS Certs:   True
SslCipherList  :

ECDHE-RSA-AES128-GCM-SHA256     - ECDHE-ECDSA-AES128-GCM-SHA256   - ECDHE-RSA-AES256-GCM-SHA384     
ECDHE-ECDSA-AES256-GCM-SHA384   - DHE-RSA-AES128-GCM-SHA256       - DHE-DSS-AES128-GCM-SHA256       
kEDH+AESGCM                     - ECDHE-RSA-AES128-SHA256         - ECDHE-ECDSA-AES128-SHA256       
ECDHE-RSA-AES128-SHA            - ECDHE-ECDSA-AES128-SHA          - ECDHE-RSA-AES256-SHA384         
ECDHE-ECDSA-AES256-SHA384       - ECDHE-RSA-AES256-SHA            - ECDHE-ECDSA-AES256-SHA          
DHE-RSA-AES128-SHA256           - DHE-RSA-AES128-SHA              - DHE-DSS-AES128-SHA256           
DHE-RSA-AES256-SHA256           - DHE-DSS-AES256-SHA              - DHE-RSA-AES256-SHA              
AES128-GCM-SHA256               - AES256-GCM-SHA384               - ECDHE-RSA-RC4-SHA               
ECDHE-ECDSA-RC4-SHA             - AES128                          - AES256                          
RC4-SHA                         - HIGH                            - !aNULL                          
!eNULL                          - !EXPORT                         - !DES                            
!3DES                           - !MD5                            - !PSK;                           
-----------------------------------------------------------------------------------------------

TCPIP PORTS                                         Connection Sec
               0.0.0.0         / 25    / SMTP   -   None
               0.0.0.0         / 110   / POP3   -   None
               0.0.0.0         / 143   / IMAP   -   None
               0.0.0.0         / 587   / SMTP   -   None
-----------------------------------------------------------------------------------------------

LOGGING      Logging Enabled: True

  Paths:-   Current:  C:\Program Files (x86)\hMailServer\Logs\hmailserver_2017-03-28.log
            Error:    C:\Program Files (x86)\hMailServer\Logs\ERROR_hmailserver_2017-03-28.log
            Event:    C:\Program Files (x86)\hMailServer\Logs\hmailserver_events.log
            Awstats:  C:\Program Files (x86)\hMailServer\Logs\hmailserver_awstats.log
                        APPLICATION -    True
                        SMTP        -    True
                        POP3        -      .
                        IMAP        -      .
                        TCPIP       -      .
                        DEBUG       -      .
                        AWSTATS     -      .
-----------------------------------------------------------------------------------------------

SYSTEM TESTS

Database type: MySQL

IPv6 support is available in operating system.

Backup directory D:\Backup\hMailserver is writable.

Relative message paths are stored in the database for all messages.

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

Generated by HMSSettingsDiagnostics v1.48, Hmailserver Forum.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
SorenR
Senior user
Senior user
Posts: 3217
Joined: 2006-08-21 15:38
Location: Denmark

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by SorenR » 2015-06-29 22:51

A plugin worth looking at...

https://github.com/eilandert/Botnet.pm
SørenR.

“With age comes wisdom, but sometimes age comes alone.”
- Oscar Wilde

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2015-10-08 11:15

In addition to my setup (above) I also use some custom rules that were once written and maintained by KOPIS.COM (written buy a man who made it his mission to tackle spam: http://khopis.com/wiki/Anti-spam). Unfortunately, the author/website of the rules (khopesh.com) is no longer active so updates to these rule definitions no longer happen (and consequently I have removed his references to the update channel of SA). However, I still have in place and use the last edition of his rules and they are very much active in scoring my Spam.

I find them useful and if you wish to continue to follow my recommendation of this thread to achieve similar results then I attach them to this post.

* OPEN the attached 3.003000.zip, and save the contents in to the equivalent of:
  • C:\Program Files (x86)\JAM Software\SpamAssassin for Windows\share\3.004000
(where '3.00400' is the folder holding the default "updates_spamassassin_org" CF and subfolder). If it helps see screenshot to how it should look:
3.004000.PNG
That's it, you now have my full setup for spamassassin and I remain more or less spam free.
Attachments
3.004000.zip
(18.1 KiB) Downloaded 684 times
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

adsmart101
New user
New user
Posts: 1
Joined: 2015-12-26 22:53

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by adsmart101 » 2015-12-26 23:02

Can you help me configure spamassassin so that it also marks the body of email with the various scores from the different categories? I think it would be cool and informative to know why spamassassin classified a certain email as spam. I thought it could do this.

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2015-12-26 23:14

If you add
add_header all Report _REPORT_ *

in to the LOCAL.CF then out gives all the headers and scores. (use my version as posted)
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

sart
New user
New user
Posts: 10
Joined: 2015-05-27 11:44

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by sart » 2016-01-25 14:30

How to make log rotate for spamd.log?

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2016-01-25 14:38

Write BAT file or include a section in your nightly housekeeping script that stops the spamassassin service, renames the current spamd.log, then restarts the service (a new spamd.log will then be created). You should be stopping and restarting the service every night anyway in order to perform a daily 'sa-update' of definitions.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

MarHMS
Normal user
Normal user
Posts: 113
Joined: 2015-12-11 17:10

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by MarHMS » 2016-02-03 18:26

jimimaseye wrote:...

Code: Select all

report_safe 0
add_header all Report _REPORT_ *
score DRUGS_ERECTILE 10

# Add *****SPAM***** to the Subject header of spam e-mails
#
rewrite_header Subject [_HITS_]

# Set the threshold at which a message is considered spam (default: 5.0)
#
required_score 3.0
...
Should I overwrite my local.cf file:

Code: Select all

# This is the right place to customize your installation of SpamAssassin.
#
# See 'perldoc Mail::SpamAssassin::Conf' for details of what can be
# tweaked.
#
# Only a small subset of options are listed below
#
###########################################################################

#   Add *****SPAM***** to the Subject header of spam e-mails
#
# rewrite_header Subject *****SPAM*****


#   Save spam messages as a message/rfc822 MIME attachment instead of
#   modifying the original message (0: off, 2: use text/plain instead)
#
# report_safe 1


#   Set which networks or hosts are considered 'trusted' by your mail
#   server (i.e. not spammers)
#
# trusted_networks 212.17.35.


#   Set file-locking method (flock is not safe over NFS, but is faster)
#
# lock_method flock


#   Set the threshold at which a message is considered spam (default: 5.0)
#
# required_score 5.0


#   Use Bayesian classifier (default: 1)
#
# use_bayes 1


#   Bayesian classifier auto-learning (default: 1)
#
# bayes_auto_learn 1


#   Set headers which may provide inappropriate cues to the Bayesian
#   classifier
#
# bayes_ignore_header X-Bogosity
# bayes_ignore_header X-Spam-Flag
# bayes_ignore_header X-Spam-Status


#   Some shortcircuiting, if the plugin is enabled
# 
ifplugin Mail::SpamAssassin::Plugin::Shortcircuit
#
#   default: strongly-whitelisted mails are *really* whitelisted now, if the
#   shortcircuiting plugin is active, causing early exit to save CPU load.
#   Uncomment to turn this on
#
# shortcircuit USER_IN_WHITELIST       on
# shortcircuit USER_IN_DEF_WHITELIST   on
# shortcircuit USER_IN_ALL_SPAM_TO     on
# shortcircuit SUBJECT_IN_WHITELIST    on

#   the opposite; blacklisted mails can also save CPU
#
# shortcircuit USER_IN_BLACKLIST       on
# shortcircuit USER_IN_BLACKLIST_TO    on
# shortcircuit SUBJECT_IN_BLACKLIST    on

#   if you have taken the time to correctly specify your "trusted_networks",
#   this is another good way to save CPU
#
# shortcircuit ALL_TRUSTED             on

#   and a well-trained bayes DB can save running rules, too
#
# shortcircuit BAYES_99                spam
# shortcircuit BAYES_00                ham

endif # Mail::SpamAssassin::Plugin::Shortcircuit
If no, then should just append it to the code?

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2016-02-03 19:26

Your existing file (which is default) consists mainly of REMMED lines (with # at the start.) That makes it effectively an empty file. You only need to copy in to you file (at the top, for example) the same lines that I have in mine (that are not remmed).

So yes, just append to the top of yours.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

MarHMS
Normal user
Normal user
Posts: 113
Joined: 2015-12-11 17:10

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by MarHMS » 2016-02-03 19:46

jimimaseye wrote:Your existing file (which is default) consists mainly of REMMED lines (with # at the start.) That makes it effectively an empty file. You only need to copy in to you file (at the top, for example) the same lines that I have in mine (that are not remmed).

So yes, just append to the top of yours.
Okay. Thanks a lot.

sart
New user
New user
Posts: 10
Joined: 2015-05-27 11:44

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by sart » 2016-02-17 11:29

jimimaseye wrote:Write BAT file or include a section in your nightly housekeeping script that stops the spamassassin service, renames the current spamd.log, then restarts the service (a new spamd.log will then be created). You should be stopping and restarting the service every night anyway in order to perform a daily 'sa-update' of definitions.
thank you
i change sa-update.bat

Code: Select all

net stop spamassasin
sa-update.exe -v -V -D --nogpg --channelfile UpdateChannels.txt
ren D:\SpamAssassin\logs\spamd.log spamd-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%-%time:~-11,2%-%time:~-8,2%-%time:~-5,2%.log
net start spamassasin

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2016-02-17 11:43

Good. And why not zip/compress the archived log file too (it will compress to 10% the size saving 90% space).

Hint: look in the hmailserver/bin directory and you will find 7za.exe which is the commandline 7-Zip program. And here is a script I (could) use in my daily housekeeping script to compress hmailserver logs:

Code: Select all

FOR /F "eol=; eol=[ tokens=1,2* delims==" %%i in ('findstr /b /l /i "Logfolder"= "%programfiles(x86)%\hMailServer\Bin\hmailserver.ini"') DO set Logpath=%%~j

"%programfiles(x86)%\hMailServer\Bin\7za" a -t7z "%Logpath%\Logs.7z" -uq0 "%Logpath%\hmailserver_????-*.log" -xr!*.7z
del "%Logpath%"\hmailserver_????-*.log
Youll figure it out (the 2nd line does the compressing).

Youre welcome. :wink:
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Whatsek
New user
New user
Posts: 4
Joined: 2008-01-26 01:12

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by Whatsek » 2016-02-25 11:57

Thank you for this guide!

I had a problem in the renaming script, if the time is for example 09:00, the leading zero is missing, so there is a space in the file name, and renaming fails.
So I changed the script a little bit:

Code: Select all

net stop spamassassin
sa-update.exe -v --nogpg --channelfile UpdateChannels.txt
set hr=%time:~0,2%
if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%
ren "C:\Program Files (x86)\hMailServer\Logs\spamd.log" spamd-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%-%hr:~-11,2%-%time:~-8,2%-%time:~-5,2%.log"
net start spamassassin


I added the two lines, and changed the hour variable in %hr

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2016-03-29 23:36

ok. Tailoring to suit your individual needs is not forbidden. :wink: :mrgreen:
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

comp1mp
New user
New user
Posts: 21
Joined: 2013-11-26 03:51

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by comp1mp » 2016-04-01 06:00

What version of nssm did you use? I can't get this to work with 2.2.4.

The service installs but upon starting it immediately pauses.
nssm1.png
nssm2.png

spamd.exe is giving a return code of 2 in event logs.

Also are you running the 32 bit version of SpamAssassin?

Thanks,
Matthew

comp1mp
New user
New user
Posts: 21
Joined: 2013-11-26 03:51

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by comp1mp » 2016-04-01 15:06

Sorry, here are the specs.
Windows Server 2008 R2 Standard (x64)
Spam Assassin for Windows 3.4.1.36 (x64)
NSSM 2.24 (x64)

comp1mp
New user
New user
Posts: 21
Joined: 2013-11-26 03:51

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by comp1mp » 2016-04-01 17:03

I figured this out.

The --round-robin flag causes a runtime exception in version 3.4.1
3.4.1 is the current (and only) version for download on Jam's site.
This occurs in both the 32x and 64x builds.
Omitting the flag solves the problem.

There are earlier versions available for download from sites like CNET, Tucows etc.
I downloaded the version form CNET which is 3.4.0, and --round-robin did not cause an exception.
Be careful though, the CNET version shows version 3.4.0-rc5 when executed in the commmand line.
Be sure you are using a production release.

So the question is, why use the --round-robin flag? My understanding is this flag is to utilize the pre-apache fork algorithm for child process management. Presumably, using the flag would prevent the service from scaling properly. From my reading, the new algorithm was written to resolve this issue.

Jimimaseye, do you know something through experience which leads you to use this flag?

Also, many thanks for posting your score handling implementation. I look forward to using it!

Please update the tutorial to reflect what I have learned.

Matthew

User avatar
RvdH
Senior user
Senior user
Posts: 817
Joined: 2008-06-27 14:42
Location: Netherlands

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by RvdH » 2016-04-06 08:46

I never used the --round-robin option, as far as i know it is an ancient feature that uses more system resources on the system running it
--round-robin

By default, spamd will attempt to keep a small number of "hot" child processes as busy as possible, and keep any others as idle as possible, using something similar to the Apache httpd server scaling algorithm. This is accomplished by the master process coordinating the activities of the children. This switch will disable this scaling algorithm, and the behaviour seen in the 3.0.x versions will be used instead, where all processes receive an equal load and no scaling takes place.
CIDR to RegEx: d-fault.nl/CIDRtoRegEx
DNS Lookup: d-fault.nl/DNSTools
DNSBL Lookup: d-fault.nl/DNSBLLookup
GEOIP Lookup: d-fault.nl/GeoipLookup

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2016-04-17 10:53

comp1mp wrote:I figured this out.

The --round-robin flag causes a runtime exception in version 3.4.1
3.4.1 is the current (and only) version for download on Jam's site.
This occurs in both the 32x and 64x builds.
Omitting the flag solves the problem.
I have just made note to this in the first post detailing the installation.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2016-05-04 10:31

comp1mp wrote:I figured this out.

The --round-robin flag causes a runtime exception in version 3.4.1
3.4.1 is the current (and only) version for download on Jam's site.
I have just downloaded and tested the latest version of 3.4.1 using my installation instructions in this HOW TO guide including the -round-robin flag. I see no such errors. viewtopic.php?f=22&p=185847#p185847
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

itsmesri
Normal user
Normal user
Posts: 59
Joined: 2014-11-07 08:30

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by itsmesri » 2016-06-02 07:18

I have done everything except below global rule, Where to set this? Please provide me location and where.

Code: Select all

2, Set a GLOBAL RULE:

Name: "ExternalScore7"
if:
X-Spam-Level (custom header) ...contains..... ******* <<-- 7 asterix
action:
Move to IMAP Folder...... Trash (or whatever your normal trash folder is on your accounts (you may choose a dedicated 'Spam' folder instead). Alternatively you can simply 'DELETE EMAIL' but that never gives you chance to review.)

Note: I also have an additional IF clause as
OR
Subject REGULAR EXPRESSION (?i:^Virus found:.*$)

this works to also remove any emails being found to contain malware by the inbound Antivirus check.
One more thing when I test SpamAssassin, I am seeing MISSING_DATE,
MISSING_HEADERS,MISSING_MID,MISSING_SUBJECT,NO_HEADERS_MESSAGE .. Was the test correct

Code: Select all

X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on COWBOYS
X-Spam-Flag: YES
X-Spam-Level: **************************************************
X-Spam-Status: Yes, score=1004.5 required=3.0 tests=GTUBE,MISSING_DATE,
MISSING_HEADERS,MISSING_MID,MISSING_SUBJECT,NO_HEADERS_MESSAGE,NO_RECEIVED,
NO_RELAYS,TVD_SPACE_RATIO autolearn=no autolearn_force=no version=3.4.1

User avatar
mattg
Moderator
Moderator
Posts: 20244
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by mattg » 2016-06-02 10:14

itsmesri wrote:I have done everything except below global rule, Where to set this?
Er, in the main rules section in the admin gui.
Not in the accounts >> rules
itsmesri wrote:One more thing when I test SpamAssassin, I am seeing MISSING_DATE,
MISSING_HEADERS,MISSING_MID,MISSING_SUBJECT,NO_HEADERS_MESSAGE .. Was the test correct

Code: Select all

X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on COWBOYS
X-Spam-Flag: YES
X-Spam-Level: **************************************************
X-Spam-Status: Yes, score=1004.5 required=3.0 tests=GTUBE,MISSING_DATE,
MISSING_HEADERS,MISSING_MID,MISSING_SUBJECT,NO_HEADERS_MESSAGE,NO_RECEIVED,
NO_RELAYS,TVD_SPACE_RATIO autolearn=no autolearn_force=no version=3.4.1
Yes, that is the point of the test.

That shows that the test worked.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

BananaAcid
New user
New user
Posts: 1
Joined: 2016-06-09 16:28

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by BananaAcid » 2016-06-09 16:34

Thats how i setted up the update as a windows scheduler task:

created: C:\ProgramData\SpamAssassin
-> that's also where i added .\logs\ to be saved

C:\ProgramData\SpamAssassin\update.cmd

Code: Select all

@echo off
cd "C:\Program Files\SpamAssassin for Windows"
net stop spamassassin
sa-update.exe -v --nogpg --channelfile UpdateChannels.txt
net start spamassassin
C:\ProgramData\SpamAssassin\install_update_task.cmd

Code: Select all

@echo off
echo installing spamassassin update task

rem  be admin - no sudo, so do 'su'
Net user administrator /active:yes

rem  setup
SchTasks /Create /SC DAILY /TN "SpamAssassin Update" /TR "cmd /c C:\ProgramData\SpamAssassin\update.cmd" /ST 03:00

rem  test
SchTasks /TN "SpamAssassin Update"

pause

Zeni
New user
New user
Posts: 12
Joined: 2013-08-05 18:19

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by Zeni » 2016-06-21 14:02

As instructed, I downloaded SpamAssasin for windows 3.41 from http://www.jam-software.com/spamassassin/index.shtml.
Funny question is that I cannot find any install or setup file. :roll: :roll:

I am using Windows Server 2012. There are some executing files such as spamassasin.exe, spamd.exe, spamc.exe etc. but clicking these only open a cmd windows and nothing else happens. :shock: :shock:

Can someone please guide me how to install SpamAssasin for windows 3.41?

User avatar
SorenR
Senior user
Senior user
Posts: 3217
Joined: 2006-08-21 15:38
Location: Denmark

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by SorenR » 2016-06-21 14:29

SørenR.

“With age comes wisdom, but sometimes age comes alone.”
- Oscar Wilde

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2016-06-21 15:08

Zeni wrote:As instructed, I downloaded SpamAssasin for windows 3.41 from http://www.jam-software.com/spamassassin/index.shtml.
Funny question is that I cannot find any install or setup file. :roll: :roll:

I am using Windows Server 2012. There are some executing files such as spamassasin.exe, spamd.exe, spamc.exe etc. but clicking these only open a cmd windows and nothing else happens. :shock: :shock:

Can someone please guide me how to install SpamAssasin for windows 3.41?
http://www.jam-software.com/spamassassin/download.shtml

Select your system. It then offers an EXE (as well as a ZIP) install executable.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Zeni
New user
New user
Posts: 12
Joined: 2013-08-05 18:19

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by Zeni » 2016-06-22 16:31

Thanks to all. With the help of answers and of course the direction by jimimaseye I am finally able to install and run SpamAssasin and use it with hmailServer. What a relief, hope to get rid of all those spams.

MrGadget
Normal user
Normal user
Posts: 44
Joined: 2011-10-23 23:47
Location: Midwest USA

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by MrGadget » 2016-07-18 18:23

Adding this because it caught me out....

Make sure in HMS Settings > Advanced > IP Ranges you have Anti-Spam checked for the appropriate ranges.

Mrj
New user
New user
Posts: 1
Joined: 2016-09-24 11:29

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by Mrj » 2016-09-24 11:34

Same problem as Zeni.
I downloaded the exe version as directed by Jimimayasey.
Reviewed JAM's manual on "Installation" which says run the "Setup" file.
But there is NO SETUP FILE in the entire directory for the Spamassassin.
What's the deal???

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2016-09-24 19:11

The answer is above.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

bluepen61
New user
New user
Posts: 1
Joined: 2010-04-24 15:42

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by bluepen61 » 2017-07-09 15:44

comp1mp wrote:What version of nssm did you use? I can't get this to work with 2.2.4.

The service installs but upon starting it immediately pauses.
nssm1.png
nssm2.png


spamd.exe is giving a return code of 2 in event logs.

Also are you running the 32 bit version of SpamAssassin?

Thanks,
Matthew
I have been running SpamAssassin for quite some time on my windows 10 pro pc and this error cropped up on 4/13/2017. I just discovered it this week after my e-mail account began getting flooded with spam. On 4/13 a slew of Microsoft Updates were applied. Any suggestions?

Btw, I tried uninstalling and reinstalling both the program and the spamd service. Neither fixed it.

I am running 64 bit.

Edit:
I fixed it by uninstalling the service, then updating nssm to 101, then reinstalling the service. Works!!

John
Last edited by bluepen61 on 2017-07-09 15:56, edited 1 time in total.

User avatar
jimimaseye
Moderator
Moderator
Posts: 8159
Joined: 2011-09-08 17:48

Re: HOW TO: Install Spamassassin For Windows and SPAMD service

Post by jimimaseye » 2017-07-09 15:51

See the previous posters solution: viewtopic.php?p=184866#p184866

He suggests its related to 'round-robin' but I was unable to produce it.
HMS 5.6.6 B2383 on Win Server 2008 R2 Foundation, + 5.6.7-B2415 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Post Reply