running conditions while looping through arrays....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I want to run filters on an pop3 inbox.

I have the following arrays which I'll get from the database-

$subject
$email
$body
$subject_like
$email_like
$body_like

I then go through each email in turn using this loop-



$popy = "{".$pop3."/pop3:110}INBOX";
  $mailbox = imap_open($popy, $un, $pw);
    $num_messages = imap_num_msg($mailbox);
if ($num_messages <= $no_srch) {$rrt = 0;} else {$rrt = $num_messages-$no_srch;}
  for($i=$num_messages; $i>($rrt); $i--) {


What I want to do is to check if the email address or subject or body of each email is exactly like any of the details stored in the arrays $subject, $email, $body and to check if the email address or subject or body contains a word or phrase from the arrays $subject_like, $email_like, $body_like.

For example-

$subject[0] = "SPAM";   $email[0]= "";
$body[0] = "";
$subject_like[0] = "";
$email_like[0] = "";
$body_like[0] = "";
// If the subject of the email = "spam"

$subject[1] = "";   $email[1]= "spam@xxxxxxxxxxx";
$body[1] = "";
$subject_like[1] = "";
$email_like[1] = "";
$body_like[1] = "";
// if the email address of the email = "spam@xxxxxxxxxxx"

$subject[2] = "";   $email[2]= "";
$body[2] = "spam body text";
$subject_like[2] = "";
$email_like[2] = "";
$body_like[2] = "";
// if the body of the email = "spam body text"

$subject[3] = "SPAM";   $email[3]= "spam@xxxxxxxxxxx";
$body[3] = "";
$subject_like[3] = "";
$email_like[3] = "";
$body_like[3] = "";
// if the subject of the email = "SPAM" AND the email address = "spam@xxxxxxxxxxx"

$subject[4] = "SPAM";   $email[4]= "";
$body[4] = "";
$subject_like[4] = "";
$email_like[4] = "";
$body_like[4] = "spam text";
// if the subject of the email = "SPAM" AND the body contains "spam text"


If any of the above conditions are met then the email message is then stored in a database and deleted of the POP3 server.

Is there a quick way of doing the above? The only way I can think of is by looping through each array for every email. This is really really slow. I'd be grateful for some help here....

Ian


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux