Printable Version of Topic
Click here to view this topic in its original format
XMail Forum > Documentation and Knowledge Base > Filters.in.tab Ran Twice?


Posted by: sc4vengr Dec 18 2007, 07:34 PM
Hey guys,

I have a question regarding the execution of a filter that I have inside filters.in.tab.

I have 3 filters installed:

xspamcpd (filters.post-data.tab)
clamav fitler by Linderman (filters.in.tab)
custom php script that updates a database (filters.in.tab)

Also, the rcpt email has a mailproc.tab that runs a small "autoreply" script that sends an automatic message, it works very well.

The problem is that when I send an email to the rcpt it is run through xspamcpd, AV scanned, php script updates its stuff and the autoreply script sends his mail BUT it looks like the php script is ran twice WHEN I have the mailproc.tab autoreply activated. Like if there was an entry inside filters.out.tab that run the php script when sending mail (automatic message from autoreply script).

If I remove the mailproc.tab file inside the rcpt folder, it solve the problem.

Here is the debug log:

CODE

Filter run: Sender = "sender@domain.net" Recipient = "rcpt@mydomain.net" Filter = "/mailsrv/MailRoot/filters/webmail/webmail_update.php" Retcode = 0
Filter run: Sender = "sender@domain.net" Recipient = "rcpt@mydomain.net" Filter = "/mailsrv/MailRoot/filters/avfilter/checkvirus.pl" Retcode = 7
Filter run: Sender = "sender@domain.net" Recipient = "rcpt@mydomain.net" Filter = "/mailsrv/MailRoot/filters/webmail/webmail_update.php" Retcode = 0
Mail was allready scanned.
Filter run: Sender = "sender@domain.net" Recipient = "rcpt@mydomain.net" Filter = "/mailsrv/MailRoot/filters/avfilter/checkvirus.pl" Retcode = 0


Content of filters.in.tab

CODE

"*"     "*"     "0.0.0.0/0"     "0.0.0.0/0"     "webmail.tab"
"*"     "*"     "0.0.0.0/0"     "0.0.0.0/0"     "av-filter.tab"


Content of filters.out.tab (empty)

CODE




Content of filters.post-data.tab

CODE

"!aex"  "/mailsrv/xspamcpd/xspamc"      "/mailsrv/xspamcpd/xspamcpd.ini"        "@@FILE"        "@@REMOTEADDR"


Content of the rcpt mailproc.tab file

CODE

"mailbox"
"external"      "0"     "0"     "/mailsrv/MailRoot/bin/autoreply"       "message@domain.net"     "@@FROM"        "Automatic reply!"      "/mailsrv/MailRoot/domains/domain.net/rcpt/autoreply.txt"     "@@TMPFILE"


Please let me know if I have missed something because I really have no clue why the php script is ran twice.

Thanks

-fred

Posted by: hschneider Dec 18 2007, 09:07 PM
Never tested it, but maybe the "mailbox" command pushes the mail thru filters.in.tab again ... run a test without "mailbox".

Posted by: sc4vengr Dec 18 2007, 09:31 PM
I did the test and without the "mailbox" line within mailproc.tab it works correctly.

Is this a bug or it's working as intended? because without the mailbox line in the mailproc file the rcpt user mailbox becomes empty.

Thanks for your help Harald.

Posted by: hschneider Dec 19 2007, 07:39 AM
IMHO it's intended: filters.in.tab is defined as being triggered when a message is stored in a user's mailbox. It is stored first, then it runs thru mailproc.tab where it is stored another time with the "mailbox" command. So storing it triggers filters.in.tab again.

You can use "mailbox" anywhere in mailproc.tab, even behind your custom filter. Modify your filter to tag the message after processing. If it is seen again, the filter can pass it thru.

Posted by: Paddy78 Dec 19 2007, 10:08 AM
QUOTE (hschneider @ Dec 19 2007, 07:39 AM)
IMHO it's intended: filters.in.tab is defined as being triggered when a message is stored in a user's mailbox. It is stored first, then it runs thru mailproc.tab where it is stored another time with the "mailbox" command. So storing it triggers filters.in.tab again.

You can use "mailbox" anywhere in mailproc.tab, even behind your custom filter. Modify your filter to tag the message after processing. If it is seen again, the filter can pass it thru.

How is that done? With an own header line?
I suppose that behaviour with the mailbox-line and filters.in.tab could cause my problem with the spool-directory

http://xmailforum.homelinux.net/index.php?showtopic=4044


Posted by: hschneider Dec 19 2007, 02:09 PM
Yes, add an additional X-Headerline, e.g.

X-AUTOREPLY_SENT: YES

I reported this already to Davide ... let's wait ... wink.gif

Posted by: sc4vengr Dec 19 2007, 10:30 PM
It works!

filter #1 xspampcd exit code 0
filter #2 clamav exit code 7 (added header)
filter #3 webmail exit code 7 (added header)
mailproc "mailbox"
filter #2 clamav exit code 0 (already scanned)
filter #3 webmail exit code 0 (already webmailed)
mailproc "autoreply"


Thanks for your help again.

fred

Posted by: hschneider Dec 20 2007, 07:36 AM
OK ... then have some nice X-Mas wink.gif

Posted by: sc4vengr Dec 20 2007, 03:26 PM
Thanks !!!!!! you too!! biggrin.gif

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)