Ronny Haryanto <[EMAIL PROTECTED]> writes:

> I'm trying to discard emails from somebody and have procmail return a
> hard error code (like 67, 77 or 100) *with* my own brief error message.
> The MTA is qmail. Currently I have "|preline procmail" in my .qmail file.
> I have tried this following recipe with partial success (email is
> discarded and bounced, but my brief error message is not there):
> 
> :0
> * ^From:.*abuser@example\.com
> {
>     EXITCODE=100
> 
>     :0
>     | echo "Permission denied"
> }

:0
* ^From:.*abuser@example\.com
{
        EXITCODE=100

        :0 f
        | echo "Piss off."

        :0 r
        |
}

In procmailese, the f flag on the first recipe inside the braces means
"filter", which makes procmail pipe the message through the specified
command, and replace the current message content with the output of the
pipe. For instance:

:0 f
| sed 's/expletive/[expletive deleted]/g'

would be a nice start at sanitizing all email passing through your
.procmailrc. :) In our instance, however, we're piping our message to echo,
which ignores the input it has been offered, and simply outputs our
message, which procmail now takes to be the message body.

The pipe with no argument makes procmail emit the current message to
standard output, with the desired effect. The r flag prevents procmail from
trying to add extraneous \r or \n characters to the output, which are
inappropriate in this context, but appropriate for normal procmail
operation. I added it mostly for aesthetic reasons on the output; try it
both ways and see for yourself.

-- 
[EMAIL PROTECTED] (Michael Handler)                          washington, dc

Reply via email to