MYplugin example for IMS/Mfilter mail servers
Posted: Thu Nov 07, 2002 6:56 pm
In the NT world there is a free mail server called IMS that works with a program Mfilter that uses plugins to
filter e-mail. NewLISP provides an alternate development platform for Mfilter plugins.
I have successfully (linked MYplugin.exe and run it as a Mfilter plugin on an IMS server. I posted this example in the IMS-Users mailing list and there may be a few people come by here to say howdy from that group.
# MYpulgin.LSP for NewLISP & Mfilter for IMS
# Contributed by Bob aka Lord High Fixer (bob@bradlee.org)
#
# This function opens MSG file specified in arg[2] and re-writes it
# to the Working Path specified in arg[1] appending the contents of
# the RCP file arg[3] as X-HEADER lines in the NEW file
#
# Replace the current MSG files path with my working path in arg(1)
# '(append (nth 1 arg-lst) (last (parse (nth 2 arg-lst) "\\")))
#
(set 'arg-lst (main-args) ; save args from calling program
'fh-h (open (nth 3 arg-lst) "read") ; RCP file for X-Header info
'fh-m (open (nth 2 arg-lst) "read") ; MSG file
; Replace the current MSG file path with the working path in arg(1) and open it.
'fh-w (open (append (nth 1 arg-lst) (last (parse (nth 2 arg-lst) "\\"))) "write")
'do-header-flag true) ; set header flag
(while (read-line fh-m) ; walk through the message
(if do-header-flag
(begin ; do header on first pass .. else: loop through message body
(set 'do-header-flag nil) ; turn flag off, were not comming back
(while (!= (set 'text-line (read-line fh-m)) "") ; loop through header
(write-line text-line fh-w))
(while (set 'text-line (read-line fh-h)) ; add RCP info as X-headers
(write-line (append "X-" text-line) fh-w))
(write-line "" fh-w) ) ; add the header break, then end the (if (begin
(write-line (current-line) fh-w))) ; else the header is done, loop through message
(close fh-m) ; close files
(close fh-h)
(close fh-w)
#
# Comment and Uncomment these lines at your own risk!!!!
#
# the following line will copy the modified "MSG" file back over the top of the origional.
; (copy-file (append (nth 1 arg-lst) (last (parse (nth 2 arg-lst) "\\"))) (nth 2 arg-lst))
#
# the following kills off the working file. Comment it out if you want to keep the file.
(delete-file (append (nth 1 arg-lst) (last (parse (nth 2 arg-lst) "\\"))))
#
(exit 1) ; and we are out of here ....
# EOF
Thats it, Linked to the NewLISP runtime enviroment results in a 165K MYplugin.exe that works !!!
filter e-mail. NewLISP provides an alternate development platform for Mfilter plugins.
I have successfully (linked MYplugin.exe and run it as a Mfilter plugin on an IMS server. I posted this example in the IMS-Users mailing list and there may be a few people come by here to say howdy from that group.
# MYpulgin.LSP for NewLISP & Mfilter for IMS
# Contributed by Bob aka Lord High Fixer (bob@bradlee.org)
#
# This function opens MSG file specified in arg[2] and re-writes it
# to the Working Path specified in arg[1] appending the contents of
# the RCP file arg[3] as X-HEADER lines in the NEW file
#
# Replace the current MSG files path with my working path in arg(1)
# '(append (nth 1 arg-lst) (last (parse (nth 2 arg-lst) "\\")))
#
(set 'arg-lst (main-args) ; save args from calling program
'fh-h (open (nth 3 arg-lst) "read") ; RCP file for X-Header info
'fh-m (open (nth 2 arg-lst) "read") ; MSG file
; Replace the current MSG file path with the working path in arg(1) and open it.
'fh-w (open (append (nth 1 arg-lst) (last (parse (nth 2 arg-lst) "\\"))) "write")
'do-header-flag true) ; set header flag
(while (read-line fh-m) ; walk through the message
(if do-header-flag
(begin ; do header on first pass .. else: loop through message body
(set 'do-header-flag nil) ; turn flag off, were not comming back
(while (!= (set 'text-line (read-line fh-m)) "") ; loop through header
(write-line text-line fh-w))
(while (set 'text-line (read-line fh-h)) ; add RCP info as X-headers
(write-line (append "X-" text-line) fh-w))
(write-line "" fh-w) ) ; add the header break, then end the (if (begin
(write-line (current-line) fh-w))) ; else the header is done, loop through message
(close fh-m) ; close files
(close fh-h)
(close fh-w)
#
# Comment and Uncomment these lines at your own risk!!!!
#
# the following line will copy the modified "MSG" file back over the top of the origional.
; (copy-file (append (nth 1 arg-lst) (last (parse (nth 2 arg-lst) "\\"))) (nth 2 arg-lst))
#
# the following kills off the working file. Comment it out if you want to keep the file.
(delete-file (append (nth 1 arg-lst) (last (parse (nth 2 arg-lst) "\\"))))
#
(exit 1) ; and we are out of here ....
# EOF
Thats it, Linked to the NewLISP runtime enviroment results in a 165K MYplugin.exe that works !!!