Another procmail configuration
Another procmail configuration
am 24.01.2007 05:00:28 von Pet Farrari
Hi,
I am having problem with setting up procmail to work with a C program I
wrote. The C program is to determine whether the domain part of the
incoming email is a forwarded email, if it is, procmail will not filter
its spam into local cyrus mail box. I m not really sure the syntax I use
in this conf file is correct or not.
Your suggestion is much appreciated.
Here is the promailrc script:
SHELL=/bin/sh
DROPPRIVS=yes
LINEBUF=32768
SENDMAILFLAGS="-oi"
LOGFILE="/var/log/spamkill/spamkill.log"
SPAMC="/usr/local/bin/spamc"
FROM="<$1>"
TO=$2
SHIFT=1
:0f
|$SPAMC -f -U /var/run/spamd.sock
:0
* ^X-Spam-Level: \*\*\*\*\*
{
USER=`echo $TO | cut -d "@" -f1`
DOMAIN=`echo $TO | cut -d "@" -f2`
# Debug statement. Comment out these Debug log lines later.
#LOG="[$$]$_: Debug: TO=$TO${NL}\n"
#LOG="[$$]$_: Debug: USER=$USER${NL}\n"
#LOG="[$$]$_: Debug: DOMAIN=$DOMAIN${NL}\n"
# Execute CYRUSUSER's personal rules
#INCLUDERC=/var/imap/procmail/user/procmail.$CYRUSUSER
# All the mail that falls through to this point will be delivered into
the user's Spam,
# INBOX folder or forwarded to external smtp server.
:0 wi
{
IS_FWD=`/usr/local/sbin/alias2user $DOMAIN`
LOG="[$$]$_: Debug: IS_FWD=$IS_FWD${NL}\n"
# theres an error when determng whether thiss a forwarded domain
* !IS_FWD ?? "-1"
{
| /usr/local/cyrus/bin/deliver -r
admin@mymaildomian.com.au admin/Inbox
# not a forwarded domain
:0
* IS_FWD ?? "0"
{
| /usr/local/cyrus/bin/deliver -r
$USER@$DOMAIN $USER/Spam
}
# Else Delivery failed. So we need to handle the error
condition.
:0 e
{
# Get the return code from the last program that ran
and report it in the logfile.
ERRORCODE=$?
LOG="[$$]$_: XX-Failed delivery ERRORCODE=${ERRORCODE}
${NL}"
}
}
}
}
:0
! -f $FROM "$@"
Thanks
Sam
Re: Another procmail configuration
am 24.01.2007 07:55:10 von Pet Farrari
Pet Farrari wrote:
> Hi,
>
> I am having problem with setting up procmail to work with a C program I
> wrote. The C program is to determine whether the domain part of the
> incoming email is a forwarded email, if it is, procmail will not filter
> its spam into local cyrus mail box. I m not really sure the syntax I use
> in this conf file is correct or not.
>
> Your suggestion is much appreciated.
>
> Here is the promailrc script:
>
> SHELL=/bin/sh
> DROPPRIVS=yes
> LINEBUF=32768
> SENDMAILFLAGS="-oi"
> LOGFILE="/var/log/spamkill/spamkill.log"
> SPAMC="/usr/local/bin/spamc"
>
> FROM="<$1>"
> TO=$2
> SHIFT=1
>
>
> :0f
> |$SPAMC -f -U /var/run/spamd.sock
>
> :0
> * ^X-Spam-Level: \*\*\*\*\*
> {
> USER=`echo $TO | cut -d "@" -f1`
> DOMAIN=`echo $TO | cut -d "@" -f2`
>
> # Debug statement. Comment out these Debug log lines later.
> #LOG="[$$]$_: Debug: TO=$TO${NL}\n"
> #LOG="[$$]$_: Debug: USER=$USER${NL}\n"
> #LOG="[$$]$_: Debug: DOMAIN=$DOMAIN${NL}\n"
>
> # Execute CYRUSUSER's personal rules
> #INCLUDERC=/var/imap/procmail/user/procmail.$CYRUSUSER
>
> # All the mail that falls through to this point will be delivered into
> the user's Spam,
> # INBOX folder or forwarded to external smtp server.
> :0 wi
> {
>
> IS_FWD=`/usr/local/sbin/alias2user $DOMAIN`
> LOG="[$$]$_: Debug: IS_FWD=$IS_FWD${NL}\n"
> # theres an error when determng whether thiss a forwarded domain
> * !IS_FWD ?? "-1"
> {
> | /usr/local/cyrus/bin/deliver -r
> admin@mymaildomian.com.au admin/Inbox
> # not a forwarded domain
> :0
> * IS_FWD ?? "0"
> {
> | /usr/local/cyrus/bin/deliver -r $USER@$DOMAIN
> $USER/Spam
> }
>
> # Else Delivery failed. So we need to handle the error
> condition.
> :0 e
> {
> # Get the return code from the last program that ran and
> report it in the logfile.
> ERRORCODE=$?
> LOG="[$$]$_: XX-Failed delivery ERRORCODE=${ERRORCODE}
> ${NL}"
> }
> }
> }
> }
>
> :0
> ! -f $FROM "$@"
>
>
>
> Thanks
> Sam
Hi,
I forgot attached error log from procmail in regard triggering this
receipts:
procmail: Extraneous ignore-write-error flag ignored
procmail: Skipped "* !IS_FWD ?? "-1""
procmail: Skipped "{"
procmail: Skipped "| /usr/local/cyrus/bin/deliver -r
admin@mymaildomain.com.au admin/Inbox"
procmail: Skipped "| /usr/local/cyrus/bin/deliver -r $USER@$DOMAIN
$USER/Spam"
procmail: Closing brace unexpected
Subject: testing
Folder: /usr/sbin/sendmail -oi -f
1244
Thanks
S
Re: Another procmail configuration
am 25.01.2007 08:42:16 von Garen Erdoisa
Pet Farrari wrote:
> Pet Farrari wrote:
>> Hi,
>>
>> I am having problem with setting up procmail to work with a C program
>> I wrote. The C program is to determine whether the domain part of the
>> incoming email is a forwarded email, if it is, procmail will not
>> filter its spam into local cyrus mail box. I m not really sure the
>> syntax I use in this conf file is correct or not.
>>
>> Your suggestion is much appreciated.
>>
>> Here is the promailrc script:
>>
>> SHELL=/bin/sh
>> DROPPRIVS=yes
>> LINEBUF=32768
>> SENDMAILFLAGS="-oi"
>> LOGFILE="/var/log/spamkill/spamkill.log"
>> SPAMC="/usr/local/bin/spamc"
>>
>> FROM="<$1>"
>> TO=$2
>> SHIFT=1
>>
>>
>> :0f
>> |$SPAMC -f -U /var/run/spamd.sock
>>
>> :0
>> * ^X-Spam-Level: \*\*\*\*\*
>> {
>> USER=`echo $TO | cut -d "@" -f1`
>> DOMAIN=`echo $TO | cut -d "@" -f2`
>>
>> # Debug statement. Comment out these Debug log lines later.
>> #LOG="[$$]$_: Debug: TO=$TO${NL}\n"
>> #LOG="[$$]$_: Debug: USER=$USER${NL}\n"
>> #LOG="[$$]$_: Debug: DOMAIN=$DOMAIN${NL}\n"
The above lines should be written:
NL="
"
LOG="[$$]$_: Debug: TO=$TO${NL}"
LOG="[$$]$_: Debug: USER=$USER${NL}"
LOG="[$$]$_: Debug: DOMAIN=$DOMAIN${NL}"
The NL variable is what defines a New Line character. The \n won't work
as you think it will. Remember, procmail is not C. It's not even really
a programing language. It's more like a fancy parser than a programing
language.
NL should be defined in your globals section near the top. It's only
purpose is to insert a new line character where appropriate because
procmail does not intuitively insert line breaks in information sent to
the procmail log.
Something like this:
# Define a New line Character. Note: The quotes on separate lines
# are deliberate. That is what defines the "new line".
NL="
"
>>
>> # Execute CYRUSUSER's personal rules
>> #INCLUDERC=/var/imap/procmail/user/procmail.$CYRUSUSER
>>
>> # All the mail that falls through to this point will be delivered into
>> the user's Spam,
>> # INBOX folder or forwarded to external smtp server.
>> :0 wi
The i flag (ignore write errors) here is irrelevant. You are starting a
procmail nested recipe block. You aren't trying to write anything here.
The i flag is used to ignore broken pipe errors when a write action
fails on a recipe. Since there will never be a case of a broken pipe in
a nested recipe, your procmail log is showing the i flag as extraneous
and is just ignoring it.
>> {
>>
>> IS_FWD=`/usr/local/sbin/alias2user $DOMAIN`
I'm assuming that this is your compiled C binary. The way you wrote this
recipe implies that you are passing a domain name to it on the command
line and are expecting the program's return code to be set to either 0
or -1. (I'm doing a but of guessing here).
This form needs to return the value on stdout in order to use it like
you intend to use it later on.
The IS_FWD variable in this case will capture any output on stdout from
your binary. The return code of the program isn't the same thing as the
stdout or stderr channels. There is a way to do what you intend in
procmail, just not like this. Will get to that later.
>> LOG="[$$]$_: Debug: IS_FWD=$IS_FWD${NL}\n"
Should be written:
LOG="[$$]$_: Debug: IS_FWD=$IS_FWD${NL}"
>> # theres an error when determng whether thiss a forwarded domain
>> * !IS_FWD ?? "-1"
The above line is asking the question, "Check to see that the IS_FWD
procmail variable does not contain the string \"-1\"
If the above condition is true, then execute the following procmail
recipe block. Only there are procmail syntax errors in the recipe block.
>> {
>> | /usr/local/cyrus/bin/deliver -r
>> admin@mymaildomian.com.au admin/Inbox
The above is a procmail syntax error, and violates the rule of needing
shell meta characters on a procmail action line. You must always start a
procmail recipe with :0 so the above line should be written:
MYPROGRAM="/usr/local/cyrus/bin/deliver"
:0
| ${MYPROGRAM} -r admin@mymaildomian.com.au admin/Inbox
>> # not a forwarded domain
>> :0
>> * IS_FWD ?? "0"
This is asking the question: Does the procmail variable IS_FWD contain
the string \"0\"
I suspect this isn't quite what you intended both forms of this are
asking almost the same question just in a different way.
* ! IS_FWD ?? "-1"
"Does IS_FWD not contain the string \"-1\" ?"
* IS_FWD ?? "0"
"Does IS_FWD contain the string \"0\" ?"
>> {
>> | /usr/local/cyrus/bin/deliver -r
>> $USER@$DOMAIN $USER/Spam
Same thing here with a procmail syntax error. This should be written:
:0 w
| /usr/local/cyrus/bin/deliver -r $USER@$DOMAIN $USER/Spam
You have shell meta characters on the action line, so that procmail rule
is satisfied, however you also need to remember to always start a
procmail recipe with :0 even recipes nested inside other recipes.
Remember, procmail isn't really a programing language. It doesn't work
like you would expect a programing language to work.
>> }
>>
>> # Else Delivery failed. So we need to handle the error
>> condition.
>> :0 e
>> {
>> # Get the return code from the last program that ran
>> and report it in the logfile.
>> ERRORCODE=$?
>> LOG="[$$]$_: XX-Failed delivery ERRORCODE=${ERRORCODE}
>> ${NL}"
>> }
>> }
>> }
>> }
>>
>> :0
>> ! -f $FROM "$@"
>>
>>
>>
>> Thanks
>> Sam
>
> Hi,
>
> I forgot attached error log from procmail in regard triggering this
> receipts:
>
> procmail: Extraneous ignore-write-error flag ignored
> procmail: Skipped "* !IS_FWD ?? "-1""
> procmail: Skipped "{"
> procmail: Skipped "| /usr/local/cyrus/bin/deliver -r
> admin@mymaildomain.com.au admin/Inbox"
> procmail: Skipped "| /usr/local/cyrus/bin/deliver -r $USER@$DOMAIN
> $USER/Spam"
> procmail: Closing brace unexpected
> Subject: testing
> Folder: /usr/sbin/sendmail -oi -f
> 1244
>
So, with all that said, here are suggested corrections to your recipe:
Note: I tend to use
${VARIABLE}
with the braces instead of
$VARIABLE
without the braces deliberately in most cases in procmail recipes
because it allows for stringing variable names together without chancing
procmail misinterpreting the variables. The style is a bit more of a
hassle but is much less prone to mistakes in the long run.
# Define a new line variable for use in procmail log lines
# Note: the quotes on separate lines here is deliberate.
NL="
"
FORMAIL=formail
DELIVER=/usr/local/cyrus/bin/deliver
SHELL=/bin/sh
DROPPRIVS=yes
LINEBUF=32768
SENDMAILFLAGS="-oi"
LOGFILE="/var/log/spamkill/spamkill.log"
SPAMC="/usr/local/bin/spamc"
# Get the from and to addresses from the procmail command line
# arguments
FROM="<$1>"
TO=$2
SHIFT=1
# Call a spam filter daemon running on a
# unix socket using a procmail filter rule.
:0f
|${SPAMC} -f -U /var/run/spamd.sock
# Based on the results of the spam filter
# run the following procmail nested recipe.
:0
* ^X-Spam-Level: \*\*\*\*\*
{
# Extract the target username from the TO variable.
USER=`echo ${TO} | cut -d "@" -f1`
# Extract the target domain name from the TO variable.
DOMAIN=`echo ${TO} | cut -d "@" -f2`
# Debug statement. Comment out these Debug log lines later.
#LOG="[$$]$_: Debug: TO=${TO}${NL}"
#LOG="[$$]$_: Debug: USER=${USER}${NL}"
#LOG="[$$]$_: Debug: DOMAIN=${DOMAIN}${NL}"
# Execute CYRUSUSER's personal rules
#INCLUDERC=/var/imap/procmail/user/procmail.${CYRUSUSER}
# All the mail that falls through to this point will be delivered
# into the user's Spam,
# INBOX folder or forwarded to external smtp server.
:0
* ? /usr/local/sbin/alias2user ${DOMAIN}
{
LOG="[$$]$_: Message delivery to admin/Inbox${NL}"
:0 wi
| ${DELIVER} -r admin@mymaildomian.com.au admin/Inbox
}
# Else not a forwarded domain
:0 E
{
LOG="[$$]$_: Message delivery to ${USER}/spam${NL}"
:0 wi
| ${DELIVER} -r ${USER}@${DOMAIN} ${USER}/Spam
}
# Delivery failed. So we need to handle the error condition.
# Get the return code from the last program that ran and
# report it in the logfile.
ERRORCODE=$?
LOG="[$$]$_: XX-Failed delivery ERRORCODE=${ERRORCODE}${NL}"
}
# This will enter a "Not spam" log entry if the above
# recipe block doesn't execute at all.
:0 E
{ LOG="[$$]$_: Not spam.${NL}" }
# Either the email didn't meet the spamc criteria for filtering
# or delivery to the cyrus folders failed for some reason.
# so forward the message to the recipient via sendmail.
LOG="[$$]$_: Message forwarded via sendmail to ${TO}${NL}"
:0 w
! -f ${FROM} "$@"
ERRORCODE=$?
LOG="[$$]$_: Message forwarding failed. ERRORCODE=${ERRORCODE}${NL}
LOG="[$$]$_: Default delivery to inbox.${NL}"
:0:
${DEFAULT}
Note the above the use of your C program. In that form it will test the
actual return code of the program itself instead of the contents of your
variable.
Hope this clears up some issues.
--
Garen
Re: Another procmail configuration
am 25.01.2007 10:40:05 von Pet
Garen Erdoisa wrote:
> Pet Farrari wrote:
>> Pet Farrari wrote:
>>> Hi,
>>>
>>> I am having problem with setting up procmail to work with a C program
>>> I wrote. The C program is to determine whether the domain part of the
>>> incoming email is a forwarded email, if it is, procmail will not
>>> filter its spam into local cyrus mail box. I m not really sure the
>>> syntax I use in this conf file is correct or not.
>>>
>>> Your suggestion is much appreciated.
>>>
>>> Here is the promailrc script:
>>>
>>> SHELL=/bin/sh
>>> DROPPRIVS=yes
>>> LINEBUF=32768
>>> SENDMAILFLAGS="-oi"
>>> LOGFILE="/var/log/spamkill/spamkill.log"
>>> SPAMC="/usr/local/bin/spamc"
>>>
>>> FROM="<$1>"
>>> TO=$2
>>> SHIFT=1
>>>
>>>
>>> :0f
>>> |$SPAMC -f -U /var/run/spamd.sock
>>>
>>> :0
>>> * ^X-Spam-Level: \*\*\*\*\*
>>> {
>>> USER=`echo $TO | cut -d "@" -f1`
>>> DOMAIN=`echo $TO | cut -d "@" -f2`
>>>
>>> # Debug statement. Comment out these Debug log lines later.
>>> #LOG="[$$]$_: Debug: TO=$TO${NL}\n"
>>> #LOG="[$$]$_: Debug: USER=$USER${NL}\n"
>>> #LOG="[$$]$_: Debug: DOMAIN=$DOMAIN${NL}\n"
>
> The above lines should be written:
> NL="
> "
> LOG="[$$]$_: Debug: TO=$TO${NL}"
> LOG="[$$]$_: Debug: USER=$USER${NL}"
> LOG="[$$]$_: Debug: DOMAIN=$DOMAIN${NL}"
>
> The NL variable is what defines a New Line character. The \n won't work
> as you think it will. Remember, procmail is not C. It's not even really
> a programing language. It's more like a fancy parser than a programing
> language.
>
> NL should be defined in your globals section near the top. It's only
> purpose is to insert a new line character where appropriate because
> procmail does not intuitively insert line breaks in information sent to
> the procmail log.
>
> Something like this:
> # Define a New line Character. Note: The quotes on separate lines
> # are deliberate. That is what defines the "new line".
> NL="
> "
>
>>>
>>> # Execute CYRUSUSER's personal rules
>>> #INCLUDERC=/var/imap/procmail/user/procmail.$CYRUSUSER
>>>
>>> # All the mail that falls through to this point will be delivered
>>> into the user's Spam,
>>> # INBOX folder or forwarded to external smtp server.
>>> :0 wi
>
> The i flag (ignore write errors) here is irrelevant. You are starting a
> procmail nested recipe block. You aren't trying to write anything here.
> The i flag is used to ignore broken pipe errors when a write action
> fails on a recipe. Since there will never be a case of a broken pipe in
> a nested recipe, your procmail log is showing the i flag as extraneous
> and is just ignoring it.
>
>>> {
>>>
>>> IS_FWD=`/usr/local/sbin/alias2user $DOMAIN`
>
> I'm assuming that this is your compiled C binary. The way you wrote this
> recipe implies that you are passing a domain name to it on the command
> line and are expecting the program's return code to be set to either 0
> or -1. (I'm doing a but of guessing here).
>
> This form needs to return the value on stdout in order to use it like
> you intend to use it later on.
>
> The IS_FWD variable in this case will capture any output on stdout from
> your binary. The return code of the program isn't the same thing as the
> stdout or stderr channels. There is a way to do what you intend in
> procmail, just not like this. Will get to that later.
>
>>> LOG="[$$]$_: Debug: IS_FWD=$IS_FWD${NL}\n"
>
> Should be written:
> LOG="[$$]$_: Debug: IS_FWD=$IS_FWD${NL}"
>
>
>>> # theres an error when determng whether thiss a forwarded domain
>>> * !IS_FWD ?? "-1"
>
> The above line is asking the question, "Check to see that the IS_FWD
> procmail variable does not contain the string \"-1\"
>
> If the above condition is true, then execute the following procmail
> recipe block. Only there are procmail syntax errors in the recipe block.
>
>>> {
>>> | /usr/local/cyrus/bin/deliver -r
>>> admin@mymaildomian.com.au admin/Inbox
>
> The above is a procmail syntax error, and violates the rule of needing
> shell meta characters on a procmail action line. You must always start a
> procmail recipe with :0 so the above line should be written:
>
> MYPROGRAM="/usr/local/cyrus/bin/deliver"
> :0
> | ${MYPROGRAM} -r admin@mymaildomian.com.au admin/Inbox
>
>
>>> # not a forwarded domain
>>> :0
>>> * IS_FWD ?? "0"
>
> This is asking the question: Does the procmail variable IS_FWD contain
> the string \"0\"
>
> I suspect this isn't quite what you intended both forms of this are
> asking almost the same question just in a different way.
>
>
> * ! IS_FWD ?? "-1"
> "Does IS_FWD not contain the string \"-1\" ?"
>
> * IS_FWD ?? "0"
> "Does IS_FWD contain the string \"0\" ?"
>
>>> {
>>> | /usr/local/cyrus/bin/deliver -r
>>> $USER@$DOMAIN $USER/Spam
>
> Same thing here with a procmail syntax error. This should be written:
> :0 w
> | /usr/local/cyrus/bin/deliver -r $USER@$DOMAIN $USER/Spam
>
> You have shell meta characters on the action line, so that procmail rule
> is satisfied, however you also need to remember to always start a
> procmail recipe with :0 even recipes nested inside other recipes.
>
> Remember, procmail isn't really a programing language. It doesn't work
> like you would expect a programing language to work.
>
>>> }
>>>
>>> # Else Delivery failed. So we need to handle the
>>> error condition.
>>> :0 e
>>> {
>>> # Get the return code from the last program that ran
>>> and report it in the logfile.
>>> ERRORCODE=$?
>>> LOG="[$$]$_: XX-Failed delivery
>>> ERRORCODE=${ERRORCODE} ${NL}"
>>> }
>>> }
>>> }
>>> }
>>>
>>> :0
>>> ! -f $FROM "$@"
>>>
>>>
>>>
>>> Thanks
>>> Sam
>>
>> Hi,
>>
>> I forgot attached error log from procmail in regard triggering this
>> receipts:
>>
>> procmail: Extraneous ignore-write-error flag ignored
>> procmail: Skipped "* !IS_FWD ?? "-1""
>> procmail: Skipped "{"
>> procmail: Skipped "| /usr/local/cyrus/bin/deliver -r
>> admin@mymaildomain.com.au admin/Inbox"
>> procmail: Skipped "| /usr/local/cyrus/bin/deliver -r $USER@$DOMAIN
>> $USER/Spam"
>> procmail: Closing brace unexpected
>> Subject: testing
>> Folder: /usr/sbin/sendmail -oi -f
>> 1244
>>
>
> So, with all that said, here are suggested corrections to your recipe:
>
> Note: I tend to use
>
> ${VARIABLE}
>
> with the braces instead of
>
> $VARIABLE
>
> without the braces deliberately in most cases in procmail recipes
> because it allows for stringing variable names together without chancing
> procmail misinterpreting the variables. The style is a bit more of a
> hassle but is much less prone to mistakes in the long run.
>
> # Define a new line variable for use in procmail log lines
> # Note: the quotes on separate lines here is deliberate.
> NL="
> "
>
> FORMAIL=formail
> DELIVER=/usr/local/cyrus/bin/deliver
> SHELL=/bin/sh
> DROPPRIVS=yes
> LINEBUF=32768
> SENDMAILFLAGS="-oi"
> LOGFILE="/var/log/spamkill/spamkill.log"
> SPAMC="/usr/local/bin/spamc"
>
> # Get the from and to addresses from the procmail command line
> # arguments
> FROM="<$1>"
> TO=$2
> SHIFT=1
>
> # Call a spam filter daemon running on a
> # unix socket using a procmail filter rule.
> :0f
> |${SPAMC} -f -U /var/run/spamd.sock
>
> # Based on the results of the spam filter
> # run the following procmail nested recipe.
> :0
> * ^X-Spam-Level: \*\*\*\*\*
> {
> # Extract the target username from the TO variable.
> USER=`echo ${TO} | cut -d "@" -f1`
>
> # Extract the target domain name from the TO variable.
> DOMAIN=`echo ${TO} | cut -d "@" -f2`
>
> # Debug statement. Comment out these Debug log lines later.
> #LOG="[$$]$_: Debug: TO=${TO}${NL}"
> #LOG="[$$]$_: Debug: USER=${USER}${NL}"
> #LOG="[$$]$_: Debug: DOMAIN=${DOMAIN}${NL}"
>
> # Execute CYRUSUSER's personal rules
> #INCLUDERC=/var/imap/procmail/user/procmail.${CYRUSUSER}
>
> # All the mail that falls through to this point will be delivered
> # into the user's Spam,
> # INBOX folder or forwarded to external smtp server.
>
> :0
> * ? /usr/local/sbin/alias2user ${DOMAIN}
Hi, Thank you very much for the correction.
Can you tell me whether this line will return true/false or "1"/"0"?
Thanks
S
> {
> LOG="[$$]$_: Message delivery to admin/Inbox${NL}"
> :0 wi
> | ${DELIVER} -r admin@mymaildomian.com.au admin/Inbox
> }
>
> # Else not a forwarded domain
> :0 E
> {
> LOG="[$$]$_: Message delivery to ${USER}/spam${NL}"
> :0 wi
> | ${DELIVER} -r ${USER}@${DOMAIN} ${USER}/Spam
> }
>
> # Delivery failed. So we need to handle the error condition.
> # Get the return code from the last program that ran and
> # report it in the logfile.
> ERRORCODE=$?
> LOG="[$$]$_: XX-Failed delivery ERRORCODE=${ERRORCODE}${NL}"
> }
>
> # This will enter a "Not spam" log entry if the above
> # recipe block doesn't execute at all.
> :0 E
> { LOG="[$$]$_: Not spam.${NL}" }
>
> # Either the email didn't meet the spamc criteria for filtering
> # or delivery to the cyrus folders failed for some reason.
> # so forward the message to the recipient via sendmail.
> LOG="[$$]$_: Message forwarded via sendmail to ${TO}${NL}"
> :0 w
> ! -f ${FROM} "$@"
>
> ERRORCODE=$?
> LOG="[$$]$_: Message forwarding failed. ERRORCODE=${ERRORCODE}${NL}
> LOG="[$$]$_: Default delivery to inbox.${NL}"
> :0:
> ${DEFAULT}
>
>
> Note the above the use of your C program. In that form it will test the
> actual return code of the program itself instead of the contents of your
> variable.
>
> Hope this clears up some issues.
Re: Another procmail configuration
am 26.01.2007 04:24:53 von Garen Erdoisa
Pet wrote:
> Garen Erdoisa wrote:
>> Pet Farrari wrote:
>>> Pet Farrari wrote:
>>>> Hi,
>>>>
>>>> I am having problem with setting up procmail to work with a C
>>>> [SNIP]
>> # All the mail that falls through to this point will be delivered
>> # into the user's Spam,
>> # INBOX folder or forwarded to external smtp server.
>>
>> :0
>> * ? /usr/local/sbin/alias2user ${DOMAIN}
>
> Hi, Thank you very much for the correction.
> Can you tell me whether this line will return true/false or "1"/"0"?
>
Not without the C source code you used.
You can invert the test though so it doesn't really matter all that much.
# The condition will match if the return code is zero.
:0
* ? /usr/local/sbin/alias2user ${DOMAIN}
{
...
}
# The condition will match if the return code is anything other
# than zero.
:0
* ! ? /usr/local/sbin/alias2user ${DOMAIN}
{
...
}
> [SNIP]
--
Garen