[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - Determining Mailbox

Determining Mailbox

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Determining Mailbox

Postby FieldDir121 » Wed Feb 01, 2006 11:55 am

I have a filter that changes the designation mailbox of a message from "In" to "Junk Mail" if it is determined to be spam.

Pretty straight forward. Search for a condition, if found move (or place) message in "Junk Mail". As a second operation for that filter I would like to be able to run a script that can determine where the message was placed rather than where it should have gone. $CurrentMailbox tells me where it should have gone, not where it went.

Is there a way for the next script to know where the message actually went?

Thanks

Scott
FieldDir121
Resident Poster
 
Posts: 149
Joined: Mon Aug 02, 2004 5:18 pm

Postby FieldDir121 » Tue Feb 14, 2006 6:10 am

I sent the same question to tech support to see what they would suggest. Slaven replied that there isn't really a way to determine the mailbox a message is placed into. What he suggested was my fall back, create a version of the script for each mailbox the message may be placed into. Complicates script maintenance a bit, but workable.

Scott
FieldDir121
Resident Poster
 
Posts: 149
Joined: Mon Aug 02, 2004 5:18 pm

Postby Sandy » Tue Feb 14, 2006 6:29 am

One of the things I do with scripts all the time is to place my own headers into incoming msgs. So I create something like "X-sgm-WhichMailbox:" where sgm is my initials and the rest is whatever I like. One can also add data to the header such as "X-sgm-WhichMailbox:=JunkMail" at any time.

Pocoscript doesn't really have a way to pass parameters from one script to another, so I use this method. That way I can query the msg in a subsequent script for what a previous script may have done.

This may not help you since once you send a msg to a mailbox no subsequent scripts will run. (Actually, I get around this limitation too by having a final script -- I call "sgmFinal" -- and ONLY it is allowed to make the final disposition of the msg; it does so by querying these headers I place into the msg in any previous scripts.)
Sandy
 

Postby FieldDir121 » Tue Feb 14, 2006 6:39 am

Sandy,

Thanks for the tips.

I simplified the question for the post. There are actually six mailboxes involved. The workarounds will require six versions of the script. It is easy to create the original copies of the script modifying the name slightly each time. The difficulty is in keeping track of which script goes with which filter, and worse yet, doing symetrical updates when all six of the scripts are revised.

As an alternative to your technique, you can save information to a temporary file, retrieving and deleting the file (if necesary) in subsequent scripts.

Scott.
FieldDir121
Resident Poster
 
Posts: 149
Joined: Mon Aug 02, 2004 5:18 pm

Postby Sandy » Tue Feb 14, 2006 7:13 am

As an alternative to your technique, you can save information to a temporary file, retrieving and deleting the file (if necesary) in subsequent scripts.

Yes, but I like to have a record of the decisions the scripts made documented right in the msg. Since that info is stored in the headers, it is never lost, AND it's never in my way since I rarely process msgs with "View All Headers" enabled.

In any case, by using either the "headers" method, or the "temp file" method, you could reduce your situation down to one script and avoid the maintainance problem you speak of. Certainly what I would do.....but to each his own.
Sandy
 

Postby FieldDir121 » Tue Feb 14, 2006 8:14 am

Sandy,

Perhaps I don't fuly understand.

Here is the current flow:
Filter 1: Search <location> For <matching text1> Perform <store in mailbox1>
Filter 2: Search <location> For <matching text2> Perform <store in mailbox2>
Filter 3: Search <location> For <matching text3> Perform <store in mailbox3>
Filter 4: Search <location> For <matching text4> Perform <store in mailbox4>

In each case the decision as to where the message will be stored is determined in the filter. What I then need is a script that will take an action based on where the message was stored.

Adding information to the message header would work, but I think you will find you will still need a separate script for each case since the script has no way of determining where the message will ultimately end up, except by knowing which filter has called the script. Since there is not a way to determine which filter called the script, the solution is that each filter must call a unique script.

Both methods require a separate script for each filter. Using your final script method will only move the unique script requirement earlier in the process.

Scott
FieldDir121
Resident Poster
 
Posts: 149
Joined: Mon Aug 02, 2004 5:18 pm

Postby Sandy » Tue Feb 14, 2006 10:56 am

Altho I do use filters for a few things, if there is any significant processing to be done I don't invoke the script via a tradition filter, but rather use the "Add Script" option on the Incoming Filters screen (Tools|Filters). Such a script is invoked for ALL incoming msgs. Then I use Poco commands in the script (e.g., ReadTo, or ReadHeader) to determine what type of msg it is, and what sort of action to take (the equilvalent of your "Filter 1: Search <location> For <matching text1> Perform <store in mailbox1>" except I can do the equilvalent of all 4 of your example filters in a single script).

Other times I allow a traditional filter to send the incoming msg to a script (as you are doing now) and then use my "add a header" technique to pass info to some subsequent script that will run via the "Add Script" facility.

A bit more complex, but much more flexible and easier to maintain.
Sandy
 

Postby FieldDir121 » Wed Feb 15, 2006 8:07 am

I wrote the scripts last night. There are 7 so far and at least two more will be needed.

Here is the stats file:

Spam Filtering statistics
25 Total Incoming Messages
1 Main Mailbox
1 Spam Address
15 Spam Entire
0 Spam Block
0 Specific
0 Would Have Been Spam Address
8 Unknown Sender
0 Reserved5
0 Reserved4
0 Reserved3
0 Reserved2
0 Reserved1

I will be adding some further information after these. That is what one of the two additional scripts are for.

Every e-mail case is covered so that the total of the destinations will equal the number of incoming messages, with two exceptions:

1) "Would Have Been Spam Address" will show how many would have been caught by the Spam Address filter if they hadn't been caught by something else first. How many were caught first will be the diffference between "Spam Address" and "Would Have Been Spam Address".

2) E-mails with file extensions I have banned, .src and .com, are deleted before they reach any other filters so they are not counted [yet]. In order to count these I will have to modify the Attachment Remover script.

From the file extension script for those interested:

Code: Select all
{ Script:  Attachment Remover.poc
{ Author:  PJR


I have included the code for one of the 7 scripts below. The line number is hard coded and the comments are case specific, otherwise the code is universal to all 7 of the "Inc<something>.poc scripts.

Code: Select all
{  IncSpamEntire - Version 1.00
{  Author: Scott Taylor - February 14, 2006
{
{  Purpose: This script updates a counter to indicate how many incoming messages have been caught
{  by the SpamEntire keyword filter.
{
{  Method: The script opens the text file where the statistics are stored, increments the count
{  for SpamEntire hits and saves the file.
{
{ Open the statistics file
Set $FileName "..\Stats.txt"        { use Pocomail main directory
OpenBody $Stats $FileName           { get existing file contents

Set #line 4                         { predefined locations
GetLine $line #line $Stats          { get text on that line, put in $line
StringPos #pos " " $line            { the numerical portion is before the space
Set $num $line                      { make a working copy
ChopString $num #pos 999            { delete all but the number
Dec #pos                            { reduce by one
ChopString $line 1 #pos             { delete number portion of the string, leaving the space

Set #num $num                       { move to numerical variable
Inc #num                            { add 1
Set $num #num                       { move back to string variable
AddStrings $num $line               { put the number back in front of the text descriptor
Set $line $num                      { put result back in $line

DeleteLine $Stats #line 1           { delete Spam Entire line from $Stats
InsertLine $Stats #line $line       { insert updated Spam Entire line
SaveBody $Stats $FileName           { Save updated file contents, overwritting the old file.
EXIT
FieldDir121
Resident Poster
 
Posts: 149
Joined: Mon Aug 02, 2004 5:18 pm

Postby FieldDir121 » Wed Feb 15, 2006 8:08 am

I wrote the scripts last night. There are 7 so far and at least two more will be needed.

Here is the stats file:

Spam Filtering statistics
25 Total Incoming Messages
1 Main Mailbox
1 Spam Address
15 Spam Entire
0 Spam Block
0 Specific
0 Would Have Been Spam Address
8 Unknown Sender
0 Reserved5
0 Reserved4
0 Reserved3
0 Reserved2
0 Reserved1

I will be adding some further information after these. That is what one of the two additional scripts are for.

Every e-mail case is covered so that the total of the destinations will equal the number of incoming messages, with two exceptions:

1) "Would Have Been Spam Address" will show how many would have been caught by the Spam Address filter if they hadn't been caught by something else first. How many were caught first will be the diffference between "Spam Address" and "Would Have Been Spam Address".

2) E-mails with file extensions I have banned, .src and .com, are deleted before they reach any other filters so they are not counted [yet]. In order to count these I will have to modify the Attachment Remover script.

From the file extension script for those interested:

Code: Select all
{ Script:  Attachment Remover.poc
{ Author:  PJR


I have included the code for one of the 7 scripts below. The line number is hard coded and the comments are case specific, otherwise the code is universal to all 7 of the "Inc<something>.poc scripts.

Code: Select all
{  IncSpamEntire - Version 1.00
{  Author: Scott Taylor - February 14, 2006
{
{  Purpose: This script updates a counter to indicate how many incoming messages have been caught
{  by the SpamEntire keyword filter.
{
{  Method: The script opens the text file where the statistics are stored, increments the count
{  for SpamEntire hits and saves the file.
{
{ Open the statistics file
Set $FileName "..\Stats.txt"        { use Pocomail main directory
OpenBody $Stats $FileName           { get existing file contents

Set #line 4                         { predefined locations
GetLine $line #line $Stats          { get text on that line, put in $line
StringPos #pos " " $line            { the numerical portion is before the space
Set $num $line                      { make a working copy
ChopString $num #pos 999            { delete all but the number
Dec #pos                            { reduce by one
ChopString $line 1 #pos             { delete number portion of the string, leaving the space

Set #num $num                       { move to numerical variable
Inc #num                            { add 1
Set $num #num                       { move back to string variable
AddStrings $num $line               { put the number back in front of the text descriptor
Set $line $num                      { put result back in $line

DeleteLine $Stats #line 1           { delete Spam Entire line from $Stats
InsertLine $Stats #line $line       { insert updated Spam Entire line
SaveBody $Stats $FileName           { Save updated file contents, overwritting the old file.
EXIT
FieldDir121
Resident Poster
 
Posts: 149
Joined: Mon Aug 02, 2004 5:18 pm


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron