Go Back   Velocity Reviews > Newsgroups > PERL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

PERL - Another procmail configuration

 
Thread Tools Search this Thread
Old 01-24-2007, 06:58 AM   #1
Default Another procmail configuration


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/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 "$@"

When this rc get triggered by an arriving email, its log shown the
following error:

procmail: Extraneous ignore-write-error flag ignored
procmail: Skipped "* !IS_FWD ?? "-1""
procmail: Skipped "{"
procmail: Skipped "| /usr/local/cyrus/bin/deliver -r
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


Pet Farrari
  Reply With Quote
Old 01-24-2007, 01:32 PM   #2
Jürgen Exner
 
Posts: n/a
Default Re: Another procmail configuration

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.


You are missing
use strict;
use warnings;
They help you find a lot of errors.

> SHELL=/bin/sh


Standard convention is to use upper case variable names for file handles
only.
The correct syntax would be

my $shell = '/bin/sh';

> DROPPRIVS=yes
> LINEBUF=32768
> SENDMAILFLAGS="-oi"
> LOGFILE="/var/log/spamkill/spamkill.log"
> SPAMC="/usr/local/bin/spamc"


Same for those declarations above

> FROM="<$1>"
> TO=$2
> SHIFT=1


Ouch! What is that supposed to do?

>> 0f
>> $SPAMC -f -U /var/run/spamd.sock

>
>> 0

> * ^X-Spam-Level: \*\*\*\*\*


I'm giving up. Too many errors.

jue


  Reply With Quote
Old 01-27-2007, 10:53 PM   #3
Joe Smith
 
Posts: n/a
Default Re: Another procmail configuration

Pet Farrari wrote:

> I am having problem with setting up procmail to work ...
>
> Here is the promailrc script:


I hope you realize that you posted this to a Perl newsgroup.
The script you posted was not written in Perl.

If you are having problems with procmail, you should post to a procmail newsgroup.
  Reply With Quote
Old 01-28-2007, 09:30 PM   #4
Randal L. Schwartz
 
Posts: n/a
Default Re: Another procmail configuration

>>>>> "Joe" == Joe Smith <> writes:

Joe> Pet Farrari wrote:
>> I am having problem with setting up procmail to work ...
>> Here is the promailrc script:


Joe> I hope you realize that you posted this to a Perl newsgroup.

And not even a valid Perl newsgroup. This group has been officially
dead since 1995 or so.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

--
Posted via a free Usenet account from http://www.teranews.com

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump