Thread: Mail Filter
View Single Post
  #11  
Old 12th July 2009, 07:55
Rescue9 Rescue9 is offline
Member
 
Join Date: Jun 2007
Posts: 52
Thanks: 4
Thanked 3 Times in 2 Posts
Default Another Edit

I've messed with the code a bit more to make it more friendly for the maildirmake area. I'm actually not sure it works yet as my ISPC3 server is currently on the inside network. I'll hook it up to the outside network tomorrow and test out the code during the day.

Here are the changes I've made to the code:
Code:
        function getRule() {

                $content = '';
                $content .= '### BEGIN FILTER_ID:'.$this->id."\n";

                $TargetNoQuotes = $this->dataRecord["target"];
                $TargetQuotes = "\"$TargetNoQuotes\"";

                $TestChDirNoQuotes = '$DEFAULT/.'.$TargetNoQuotes;
                $TestChDirQuotes = "\"$TestChDirNoQuotes\"";

                $MailDirMakeNoQuotes = $TargetQuotes.' $DEFAULT';

                $EchoTargetFinal = $TargetNoQuotes;


                if($this->dataRecord["action"] == 'move') {

                $content .= "
`test -e ".$TestChDirQuotes."`
if ( ".'$RETURNCODE'." != 0 )
{
  `maildirmake -f $MailDirMakeNoQuotes`
  `chmod -R 0700 ".$TestChDirQuotes."`
  `echo \"INBOX.$EchoTargetFinal\" >> ".'$DEFAULT'."/courierimapsubscribed`
}
";
                }

                $content .= "if (/^".$this->dataRecord["source"].":";

Here is the output of the code box:
Code:
### BEGIN FILTER_ID:8

`test -e "$DEFAULT/.Yahoo Groups.BGT"`
if ( $RETURNCODE != 0 )
{
  `maildirmake -f "Yahoo Groups.BGT" $DEFAULT`
  `chmod -R 0700 "$DEFAULT/.Yahoo Groups.BGT"`
  `echo "INBOX.Yahoo Groups.BGT" >> $DEFAULT/courierimapsubscribed`
}
if (/^Subject:.*\[backpackgeartest\]/:h)
{
exception {
ID8EndFolder = "$DEFAULT/.Yahoo Groups.BGT/"
to $ID8EndFolder
}
}
### END FILTER_ID:8
Wrapping the code in quotes effectively handles mail folders with spaces. I've also verified that all commands work as written and that the quotes don't break the command.

I'm not quite clear on how maildrop handles the .mailfilter file enough yet, but one of the things that I'm worried about is the 'test -e' line. My understanding of the test cmd is that it doesn't return anything. If this is the case, then the $RETURNCODE variable should always be null. how can you evaluate a null variable.

Maybe the line should read:
Code:
`test -e ".$TestChDirQuotes." && exit 1 || exit 0`
if ( ".'$RETURNCODE'." != 1 )
Till or Falko care to comment on this test statement? Am I thinking correctly, or does maildrop interpret this correctly as is?

Last edited by Rescue9; 12th July 2009 at 07:59.
Reply With Quote
Sponsored Links