A processor/filter callable from procmail to do a variety of things:
The following global variables may be useful to you when writing your own part handlers:
The program takes the following switches:
test.txt instead of from STDIN.
Three part handlers are defined for processing mail. The firing of these handlers is (mostly) controlled by two special header item flags in perljacket.filter.
Some routines are supplied which should be handy for writing part handlers:
The arguments are:
get_body()delete_part()subscript => $subscript filename => name of the file to read
Additionally, the error handler can expect to see:
error => an error message and the reader handler can expect to see:
file => a reference to the filehandle
perljacket supports mail-based updates of the filter file. To use this feature, perljacked must be invoked with the -t option.
To perform a mail-based update, you send a message with the subject line
REQUEST UPDATE COOKIE and perljacket returns the message with a new subject line containing a cookie and time-to-live, and with the body of the message containing the current filters and instructions on how to add and delete filter records (basically you put ADD or DELETE at the beginning of the line).
To apply the changes, you then send the e-mail back with a subject line of
Re: UPDATE COOKIE... basically tacking "Re: " onto the front of the subject line of the message that perljacket sent to you. perljacket will then send a message detailing which changes were successfully applied and which ones were not.
perljacket uses a file containing rules to scan headers and add header lines to each message for rules which match. The file has the following format.
That should be self-explanatory!
Filter definition lines follow a modified XML syntax where the following three tags must occur in the order given, and all on one line:
These work more or less like ordinary Perl variables being interpolated into the expressions.
chuckie123@mail.somewhere.net, $from_domain will interpolate
somewhere.net.
A special Expr cliche is provided primarily for use with turning on and off rewriting.
Certain cliches are provided for commonly-used groups of headers:
Two cliches are provided for the Header item which control rewriting (deletion of text/html parts, rewriting of alternative and parallel parts as attachments, etc.). These cliches are applied sequentially.
For example if you say apply rewrites to all, and then have a line later in the filter file saying don't apply rewrites when ``foo'' matches, then the rewrite will be performed in all cases except where ``foo'' matches.
However, if you first had a rule saying don't apply rewrites when ``foo'' matches, and then later had a line saying apply rewrites to all, then the rewrite would be performed regardless of whether or not ``foo'' matches.
Basically, rewriting is a flag which toggles on and off as rules are evaluated. (The default state is no rewrites)
v2.00 FWM 18-May-2002 at_Header() Make the mail-based filtering stuff a subroutine to get it out of the
main-line at_Header processing.
v2.00 FWM 18-May-2002 at_Entity() Check the Content-Type for a name to use for attachments.
v2.00 FWM 19-May-2002 at_Header(), at_Multipart(), at_Entity() Implement rewrite switch.
v2.00 FWM 19-May-2002 at_Header() Get rid of extra newline during text/html rewrite.
v2.01 FWM 21-May-2002 at_Header() text/html rewrite: get rid of some extra
quotes around the Content-Type charset.
v2.01 FWM 21-May-2002 level() MIME boundary detection: \G didn't seem to
be reliable on some platforms with long multiline Content-Type headers.
v2.02 FWM 22-May-2002 at_Entity() Write the X-PerlJacket header after the Content-Type header for
superstitious reasons.
v2.03 FWM 18-Aug-2002 at_Entity() Fix a problem with some tnefs still getting through.
v2.04 FWM 14-Dec-2002 ... Technically, you cant exit out of a do.. construct with next. It looks good, and works fine, but in the interest of correctness I've gone through the places where I was using do.. to implement case structures and gone to something a little more couth.
v2.04 FWM 23-Dec-2002 level() Stop it from eating lines which consist of nothing but
two dashes. (Tip 'o th' hat to BLB of NLRC for bringing this to my attention)
v2.05 FWM 20-Dec-2003 build_interpolation(),at_header() Implement ability to substitute
certain Perlish symbols cadged from the headers into expressions, starting with from_domain.
v2.06 FWM 05-May-2004 ... Implement -f which causes PJ to read from test.txt instead
of STDIN... useful if invoking with perl -d.
v2.06 FWM 05-May-2004 line(),level() Silly rabbit, tricks are for pigs!
v2.07 FWM 21-May-2004 read_from_file() Weird SuSE 8.2/Perl 5.8 thing. It wants to do some
MIDI ioctl thing with ordinary files, and leaves $! set after successful opens. Do I
know why? Do I care??
PerlJacket written by and (c) 2002-2004 Fred Morris, Seattle WA. USA e-mail: m3047@inwa.net telephone: 206.297.6344
You are granted a royalty-free, perpetual license as follows:
You may use PerlJacket at your own risk, subject to your own determination that it performs acceptably for your needs. PerlJacket is provided as-is, and with no warranty as to performance or fitness for a particular use. PerlJacket does not conform strictly to the specifications for mail and MIME defined in the IETF RFCs; it performs as the author desires it to perform. If it does not perform as you wish it to, you must cease use, or modify it to suit your own needs. As a condition of this license you agree to hold the author and Fred Morris Consulting harmless for any and all damages, whether direct, consequential or arising from any other theory of law. You may copy, redistribute, modify or create derivative works provided that you give the author proper attribution and furthermore agree to indemnify him against any claims arising from its use by you or others. You have not been required to compensate the author or Fred Morris Consulting in consideration for this license, and you waive all rights to monetary compensation should a claim be upheld. You agree that any claims or other actions pertaining to PerlJacket, its use or this license will be brought in a court of competent jurisdiction in the State of Washington, USA.