PDA

View Full Version : Custom Filter


surf22
08-17-2005, 12:51 PM
Our goal is to send of copy of certain messages based on the subject to a certain email address. After searching the knowledge base I came up with this which we are using as a simple filter:

forward (email address removed for privacy reasons) sh -c '822field subject | grep -qiFf "/big/dom/xbakercommunications/badsubj.txt"'

Which seems to works fine from a filtering/redirect point of view but occasionally senders to the original address (not using that subject) get the following error:


-----Original Message-----
From: MAILER-DAEMON@lola.futurequest.net
[mailto:MAILER-DAEMON@lola.futurequest.net]
Sent: Wednesday, August 17, 2005 11:30 AM
Subject: failure notice

Hi. This is the qmail-send program at lola.futurequest.net.
I'm afraid I wasn't able to deliver your message to the following
addresses. This is a permanent error; I've given up. Sorry it didn't
work out.

<sh@lola.futurequest.net>:
Sorry, no mailbox here by that name. (#5.1.1)

<-c@lola.futurequest.net>:
Sorry, no mailbox here by that name. (#5.1.1)

<822field subject | grep -qiFf
"/big/dom/xbakercommunications/badsubj.txt"@lola.futurequest.net>:
Sorry, no mailbox here by that name. (#5.1.1)

--- Below this line is a copy of the message.

Return-Path: <(email address removed for privacy reasons)>
Received: (qmail 688 invoked by uid 47202); 17 Aug 2005 16:29:50 -0000
Delivered-To: (email address removed for privacy reasons)
Received: (fqmail 8799 invoked from network); 17 Aug 2005 16:29:50 -0000
Received: from mx06.futurequest.net (mx06.futurequest.net [69.5.6.177])
by pt03.futurequest.net ([69.5.6.179])
with FQDP via TCP; 17 Aug 2005 16:29:50 -0000
Received: (qmail 12268 invoked from network); 17 Aug 2005 16:29:50 -0000
Received: from lola.futurequest.net (lola.futurequest.net [69.5.12.2])
by mx06.futurequest.net ([69.5.6.177])
with SMTP via TCP; 17 Aug 2005 16:29:50 -0000
Received: (qmail 1110 invoked from network); 17 Aug 2005 16:29:50 -0000
Received: from bakercommunications.com (bakercommunications.com
[69.5.12.104])
by lola.futurequest.net ([69.5.12.2]); 17 Aug 2005 16:29:50 -0000
Received: from goldsg3h5la5zz ([69.22.3.12])
by bakercommunications.com ([69.5.12.104])
with ESMTP via TCP; 17 Aug 2005 16:29:50 -0000
(email address removed for privacy reasons)Date: Wed, 17 Aug 2005 11:29:48 -0500
Message-ID: <00b301c5a348$e30beeb0$6501a8c0@goldsg3h5la5zz>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_00B4_01C5A31E.FA35E6B0"
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook, Build 10.0.6626
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180

This is a multi-part message in MIME format.

------=_NextPart_000_00B4_01C5A31E.FA35E6B0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Am wondering why this is and how to fix it?

Don
08-17-2005, 02:01 PM
The forward command only forwards; it interprets every argument as an email address to be forwarded to. Did you mean to use the condredirect command?

--
Don

surf22
08-17-2005, 02:08 PM
condredirect simply redirects the message, the goal it to keep the original message and just copy someone else (i.e. a CC of the message.) As I said the forwarding isn't the issue, the problem is the error message being randomly generated.

Bruce
08-17-2005, 03:05 PM
condredirect simply redirects the message, the goal it to keep the original message and just copy someone else (i.e. a CC of the message.) As I said the forwarding isn't the issue, the problem is the error message being randomly generated.As said before, the "forward" command interprets every command-line argument as an address, and so tries to deliver email to addresses named "sh", "-c" etc. This is different than condredirect which does take a command to test. What you want is something like this:
if 822field subject | grep -qiFf "/big/dom/xbakercommunications/badsubj.txt"; then forward EMAILADDRESS; fi

surf22
08-22-2005, 11:35 AM
What you want is something like this:
if 822field subject | grep -qiFf "/big/dom/xbakercommunications/badsubj.txt"; then forward EMAILADDRESS; fi

I have replaced EMAILADDRESS with the correct email but it is not forwarding, is the "fi" at the end correct?

kitchin
08-22-2005, 11:41 AM
Indeed "fi" is unix's humorous way of ending an "if" statement. Are you using a full@domain.tld email address?

Arthur
08-22-2005, 12:05 PM
I have replaced EMAILADDRESS with the correct email but it is not forwarding, is the "fi" at the end correct? Like kitchin said, the "fi" is correct and is the closing statement for the "if".

What was the subject of the test email you sent and what is in your badsubj.txt file?

Arthur