/****************************************************************/ /* Filter for use with Weasel */ /* */ /* Filter for use with SpamAssassin (www.spamassassin.org */ /* SpamAssassin needs to be installed as per INSTALL in */ /* the .zip file from the website */ /* */ /* This module works in conjunction with sa_filter.cmd */ /* and should be run using multifilter.cmd */ /* */ /* Create mail accounts spam@ & nonspam@ */ /* Forward/bounce mail that Spam Assassin classifies */ /* incorrectly to the appropriate address. */ /* */ /* */ /* */ /* Author: Paul Smedley (paul@smedley.info) */ /* Started: 23 September 2003 */ /* Last revised: 23 September 2003 */ /* */ /* Installation: */ /* Put this file in the directory containing WEASEL.INI */ /* Put its name in the 'Filter 4' line in the 'Filters' */ /* page in Setup. */ /* Weasel needs to be restarted to recognise the change. */ /* */ /****************************************************************/ CALL RxFuncAdd SysLoadFuncs, rexxutil, sysloadfuncs CALL SysLoadFuncs PARSE ARG userlist SrcFile SrcFile = STRIP(SrcFile) SrcFile = TRANSLATE(SrcFile, '\', '/') /* Read through the header of SrcFile, ignoring everything except */ /* the "To:" line. */ InHeader = 1 found = 0 resultcode = 0 DO FOREVER /* Each time around this loop we look at one line of */ /* the header. */ line = TRANSLATE(LineIn(SrcFile)) IF line = "" THEN LEAVE ELSE IF (LEFT(line,1) = ' ') | (LEFT(line,1) = '09'X) THEN DO /* Continuation line, no need to process it. */ END ELSE IF POS(':', line) = 0 THEN LEAVE ELSE DO PARSE VALUE line WITH keyword ':' remainder IF keyword = "TO" THEN DO say line IF POS('NONSPAM@', line) > 0 THEN DO /* "addressed to nonspam@ - teaching SA that this is NOT Spam" */ 'e:\perllib\bin\perl.exe e:\perllib\bin\sa-learn --nonspam --file ' SrcFile '>nonspam.log' resultcode=2 LEAVE END IF POS('SPAM@', line) > 0 THEN DO /* "addressed to spam@ - teaching SA that this is Spam" */ 'e:\perllib\bin\perl.exe e:\perllib\bin\sa-learn --spam --file ' SrcFile '>spam.log' resultcode=2 LEAVE END END END END CALL stream SrcFile, 'C', 'CLOSE' /* Return to Weasel with the result code. */ RETURN resultcode