procmail
[Top] [All Lists]

Re: Pulling out entire body

1999-07-10 08:45:34
"Daniel R. Sullivan" <dan(_at_)wildtangent(_dot_)com> writes:
Ok, I've read the FAQ and tutorials, but I'm still lost.  I'm trying to take
the most important lines out of the header, and put the entire body into a
file, or pass them all to my perl script that inserts them into a MySQL
database. The concept is to have all mail that goes to a certain account be
entered directly into the database, so our support guys can make sure the
email is replied to, and not replied to multiple times.

Here is what I've come up with so far:

SUBJECT=`formail -zxSubject:`
FROM=`formail -zxFrom:`
:0bf:
#:0:
#*:[   ]\/[^   ].*
| script.pl -s "$SUBJECT" -s "$FROM" >>output4
IN.testing

I left my comments in there, but it would even be Ok if I saved the message
as a file, and
passed the subject and From lines to a script, and then loaded the body
(with or without header) from a file from inside the script.

Your first problem is that you don't want the 'f' flag on that recipe.
With the 'f' flag, procmail capture the output of the action, make that
the body of the message, and then continue processing the rcfile.
Since you're redirecting the output of the script to "output4",
procmail has nothing to capture and you should be seeing bodyless
messages in your mailspool or some other mailbox.  Instead of the 'f'
flag you should be using the 'c' flag which just tells procmail to
deliver a copy of the message to this program and then continue the
rcfile.

Your next problem is that you have a mailbox name without a recipe.
That last line, "IN.testing" is probably generating error messages in
you logfile that say:
        Skipped: "IN.testing"

If you want the IN.testing mailbox to receive a copy of each message
handled by the program then you should make it a full recipe:

        :0 A:  IN.testing

The 'A' flag tells procmail to do this deliver if and only if the
preceeding recipe matched.

So, the full rcfile snippet should look something like:

        SUBJECT=`formail -zxSubject:`
        FROM=`formail -zxFrom:`

        :0bc:
        | script.pl -s "$SUBJECT" -s "$FROM" >>output4

            # Indented to enhance reabability and show the dependence
            # on the previous recipe.
            :0 A:
            IN.testing


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>