Install instructions for the local_scan.c perl plugin

You first need to read the instruction on exim.org for the local scan API. This contains general install instruction ( for the current version of exim these are here ).

Since this plugin uses perl you will need some extra include and library linking commands. On linux I use the following two extra shell variables ->

INCLUDE="-I`perl -MConfig -e 'print $Config{archlib}'`/CORE"
EXTRALIBS="-Wl,--export-dynamic -L`perl -MConfig -e 'print $Config{archlib}'`/CORE `perl -MConfig -e 'print $Config{archlib}'`/auto/DynaLoader/DynaLoader.a -lperl -lm -ldl"

The first line makes sure that the perl include files are found and the second ensures that correct perl libraries are linked to exim.

Under the currently tested version of Exim for this plugin ( 4.04 ) you will also need the following patch for Makefile-Base ->

diff -urN exim-4.04-pristine/OS/Makefile-Base exim-4.04/OS/Makefile-Base
--- exim-4.04-pristine/OS/Makefile-Base Thu Apr 18 09:08:27 2002
+++ exim-4.04/OS/Makefile-Base  Wed Jul  3 10:27:05 2002
@@ -502,7 +502,7 @@
 em_xs.o:         ../exim_monitor/em_xs.c      ../exim_monitor/em_hdr.h
 em_version.o:    ../exim_monitor/em_version.c ../exim_monitor/em_hdr.h
 $(MONBIN): $(HDRS)
-                $(CC) -o $@ -c $(CFLAGS) $(INCLUDE) $(XINCLUDE) -I. -I../exim_monitor \
+                $(CC) -o $@ -c $(CFLAGS) $(XINCLUDE) -I. -I../exim_monitor $(INCLUDE) \
                   ../exim_monitor/`echo $@ | sed 's/o$$/c/'`
 
This swaps around the order of include's otherwise the perl 'config.h' clobbers the exim 'config.h'.

Once compiled and installed the plugin expects to find a perl script at /usr/sbib/local_scan.pl with a subroutine local_scan in it. Anything else causes an error. All the variables available to the C local_scan API are available in the perl script. It is advisable to use the Exim::LocalScan library so that they are all imported for you. The headers and recipient lists are available as arrays and the body of the message is given as the first argument to the local_scan sub. Exim::LocalScan provides three subroutines -> LOCAL_SCAN_ACCEPT, LOCAL_SCAN_REJECT and LOCAL_SCAN_TEMPREJECT so that you can finish your local_scan routine with the following ->

return LOCAL_SCAN_ACCEPT; 
as you would do in the C API. Setting the $return_text variable sets the return message for failures. There is an example local_scan.pl in the Exim::LocalScan distribution that prints all the variables to a file and accepts the message, see this for a hint as to how this all works.

Any problems please email the Author.