[pmmail-list] How do I: scan email body for correct email address?

Boris Kirkorowicz pmmail-list@blueprintsoftwareworks.com
Fri, 27 Jul 2001 19:29:11 +0200 (MSZ)


On Fri, 27 Jul 2001 10:53:22 -0400 (EDT), Stanley Sidlov wrote:

>I know that I have to write a rexx hook to parse the email body for the address,
>but once I know that,  how do I substitute that address to use 
>in a canned reply? Can the rexx hook send it's own email without PMMail 
>-- I would rather not, since I would like the Sent Mail box to have a 
>copy.....

Maybe my AntiSPAM-script may help you. Use it as an example, an suggestion 
or template for your own scripts:

==============================CUT==============================
/***************************************************************************/
/*                                                                         */
/* PMMail-UserUnknown.cmd         Boris Kirkorowicz             26.06.2001 */
/*                                                                         */
/***************************************************************************/
/*                                                                         */
/* Description:                                                            */
/* PMMail-CapteinUserUnknown.cmd SPAM-Mailfile                             */
/*                                                                         */
/* Sends a "user unknown" message according to the given file.             */
/*                                                                         */
/***************************************************************************/
call RxfuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
call SysLoadFuncs

/* Get data */
dir = directory('F:\BSW-Inc\PMMail')
tempdir = dir||'\TEMP'
logmode = 0
logfile = tempdir||'\PMMail-UserUnknown.log'
SPAMcopy = tempdir||'\SPAMcopy.txt'
sourcefile = 'F:\BSW-Inc\PMMail\POSTMA0.ACT\UserUnknown.txt'
tempfile = tempdir||'\UserUnknown.tmp'
tempfile2 = tempdir||'\UserUnknown2.tmp'

PARSE ARG SPAMmail
ADDRESS CMD 'type 'SPAMmail' > 'SPAMcopy
IF logmode THEN CALL LINEOUT logfile, 'SPAMmail: 'SPAMmail
IF logmode THEN CALL LINEOUT logfile, 'SPAMcopy: 'SPAMcopy


/* Analyze mail file */
CALL STREAM SPAMcopy, 'C', 'OPEN'
DO WHILE LINES(SPAMcopy)
   line = LINEIN(SPAMcopy)
   IF line = '' THEN LEAVE
   PARSE VAR line keyword keyvalue
   IF logmode THEN CALL LINEOUT logfile, 'line: 'line
   IF logmode THEN CALL LINEOUT logfile, 'keyword: 'keyword
   IF logmode THEN CALL LINEOUT logfile, 'keyvalue: 'keyvalue


   SELECT
      WHEN keyword = 'From:' THEN SPAMaccount = keyvalue
      WHEN keyword = 'To:' & (RIGHT(keyvalue,7) = 'kirk.de' | RIGHT(keyvalue,8) = 'snafu.de') THEN SPAMmed = keyvalue
      WHEN keyword = 'Envelope-to:' & (RIGHT(keyvalue,7) = 'kirk.de'  | RIGHT(keyvalue,8) = 'snafu.de') THEN SPAMmed = keyvalue
      OTHERWISE NOP
   END

   IF SPAMmed <> 'SPAMMED' & SPAMaccount <> 'SPAMACCOUNT' THEN LEAVE
END
CALL STREAM SPAMcopy, 'C', 'CLOSE'

IF logmode THEN CALL LINEOUT logfile, 'SPAMaccount: 'SPAMaccount
IF logmode THEN CALL LINEOUT logfile, 'SPAMmed: 'SPAMmed
IF logmode THEN CALL LINEOUT logfile


/* write "user unknown" message */
CALL LINEOUT tempfile, 'This message was created automatically by mail delivery software.'
CALL LINEOUT tempfile, ''
CALL LINEOUT tempfile, 'A message that you sent could not be delivered to one or more of its'
CALL LINEOUT tempfile, 'recipients. This is a permanent error. The following address(es) failed:'
CALL LINEOUT tempfile, ''
CALL LINEOUT tempfile, SPAMmed
CALL LINEOUT tempfile, ''
CALL LINEOUT tempfile, '    SMTP error from remote mailer after RCPT TO:<'SPAMmed'>:'
CALL LINEOUT tempfile, '    host mailgate.kirk.de: 550 {mx008-rz3} <'SPAMmed'>... User unknown or not available - Empfaenger unbekannt oder nicht erreichbar'
CALL LINEOUT tempfile, SPAMmed
CALL LINEOUT tempfile, ''
CALL LINEOUT tempfile, '------ This is a copy of the message, including all the headers. ------'
CALL LINEOUT tempfile

/* append mail file */
ADDRESS CMD 'copy 'tempfile tempfile2
ADDRESS CMD 'copy 'tempfile2' + 'SPAMcopy' 'tempfile
IF SPAMaccount = 'SPAMACCOUNT' | SPAMmed = 'SPAMMED' THEN EXIT 2

/* Send mail */
ADDRESS CMD 'F:\BSW-Inc\PMMail\PMMSend.exe /m 'tempfile' "'SPAMaccount'" "Mail delivery failed: returning message to sender" POSTMA0.ACT'

/* Clean up */
ADDRESS CMD 'del 'tempfile
ADDRESS CMD 'del 'tempfile2
ADDRESS CMD 'del 'SPAMcopy

EXIT
==============================CUT==============================

Using that script (especially the line containing PMMSend.exe),
I have the message in the sent folder of my Postmaster account (POSTMA0.ACT).
I hope it works, although I stripped some unnecessary lines and translated
some comments and variables... ;->

You may enhance it e.g. by automatically generate a complaint mail
to an mail abuse instance like spamcop... ;-)








Gruß                              Greetings
          Boris Kirkorowicz

- pmmail-list - The PMMail Dicussion List ---------------------------
To UNSUBSCRIBE, send a message to mdaemon@bmtmicro.com with the first 
line of the message body being...
UNSUBSCRIBE pmmail-list@blueprintsoftwareworks.com