Re: running conditions while looping through arrays....
| From: | Richard Lynch | Date: | Tue, 20 Jun 2006 00:16:32 +0000 |
| Subject: | Re: running conditions while looping through arrays.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238353@lists.php.net to get a copy of this message | ||
On Mon, June 19, 2006 11:05 am, IG wrote:
> I want to run filters on an pop3 inbox.
You may want to just use IMAP protocol...
> 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-
I do it just like this:
http://l-i-e.com/imap/index.phps
> $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@spammer.com";
> $body[1] = "";
> $subject_like[1] = "";
> $email_like[1] = "";
> $body_like[1] = "";
> // if the email address of the email = "spam@spammer.com"
>
> $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@spammer.com";
> $body[3] = "";
> $subject_like[3] = "";
> $email_like[3] = "";
> $body_like[3] = "";
> // if the subject of the email = "SPAM" AND the email address =
> "spam@spammer.com"
>
> $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....
I found that using SpamAssassin (SA), and setting up a different
directory for each 'score' in SA and then sorting my incoming email
for a month by 'score' into those boxes...
pretty much, everything scoring higher than 1 or 2 was spam.
After I trashed all 3+ SA, my own personal spam filters in PHP were
pretty superfluous.
--
Like Music?
http://l-i-e.com/artists.htm