Re: procmail recipe for a given message body



On Sun, 02 Sep 2007 13:16:36 +0200, Keve Nagy <nospam@xxxxxxxxxxxxxxx> wrote:
Hi Everyone,
Some of you experienced with procmail hopefully can help me out
with this. I am trying to construct a procmail recipe which
filters for a given message-body.

I a cron scheduled script which do a shutdown as its final
instruction always generates a mail with the message body of:

_example_starts_here_

shutdown: [pid 1315]
Shutdown at Thu Aug 30 06:42:35 2007.
Shutdown at Thu Aug 30 06:42:35 2007.

System shutdown time has arrived

_end_of_example_

As you can see the pid. the date and time is always expected to
be defferent, but the rest of the message is constant. I'd like
to filter these messages out.

You can always use a regular expression to match the parts which
happen to "change over time":

:0 B
* ^shutdown: \[pid [0-9][0-9]*\]
/dev/null

I wasn't able to put together the facts on how to construct a
recipe for that. If you have a suggestion or a pointer to an
example or guide on this, please let me know. Unfortunatelly,
none of the procmail articles on the web I came accross dealt
with filtering for a given message-body.

It's probably going to be a bit more "resource intensive" to
filter messages based on regular expression matches on the "body"
of the message, but since you need it it's probably ok. The part
of the message which matching rules are applied to can be
controlled by the "flags" after the :0 part. I've used "B" there
to ask procmail to match the "body" of the message, instead of
the "headers".

For future reference, the "flags" are explained in the
procmailrc(5) manpage, near the part which says:

% Recipes
% A line starting with ':' marks the beginning of a recipe.
% It has the following format:
%
% :0 [flags] [ : [locallockfile] ]
% <zero or more conditions (one per line)>
% <exactly one action line>
%
% Conditions start with a leading `*', everything after that
% character is passed on to the internal egrep literally,
% except for leading and trailing whitespace. These regular
% expressions are completely compati- ble to the normal
% egrep(1) extended regular expressions. See also Extended
% regular expressions.
%
% Conditions are anded; if there are no conditions the result
% will be true by default.
%
% Flags can be any of the following:
%
% H Egrep the header (default).
%
% B Egrep the body.
%
% [ more flags explained here ]

.



Relevant Pages

  • Re: [opensuse] Custom filters in Kwrite
    ... On Sun, Mar 30, 2008 at 2:30 AM, Stan Goodman ... >> implement using the filter available scheme. ... > To do more sophisticated mail filtering procmail is probably a better ... The alternative might be just to write a regular expression working against ...
    (SuSE)
  • Re: [SLE] Copy spool mail files?
    ... Knowing next to nil about imap, this is as close as I can come: ... Postfix is a mail transfer agent which handles SMTP ... Procmail is used to actually deliver the email, ... SpamAssassin is a spam email filter. ...
    (SuSE)
  • Re: Procmail losing mail?
    ... the first part will pass the data pipe to an ... pipes it's filtered results on to the egrep command. ... That in turn is tested in the next recipe. ... to the procmail log file, but could do anything you want it to do. ...
    (comp.mail.misc)
  • Re: netiquette: CCing on lists
    ... > charity of the mailing list posters to ca= ter to their reply whims. ... the duplicate check filter can be found in the ... > procmail-lib Debian package, or I can mail a copy to you offlist. ... this, I don't receive the dupes through my spool, so procmail won't do ...
    (Debian-User)
  • Re: Question about Kmail filters
    ... server a copy of the downloaded mail. ... I would like to set up a filter that: ... You setup fetchmail to fetch the mail for your from the pop account (if you have other mailboxes, you can let it to fetch them all) and deliver the mail to procmail for local delivery. ...
    (comp.windows.x.kde)