Hi,

This code works fine as long as you only have 1 email
in your inbox.  If there is more than 1 than it will
return the last emails from: address rather than look
in the $body for what's it meant to.

So I am looking for a solution.  One I thought which
could be the simpliest way is to display one email at
a time, rather than trying to grab all records in  one
go.  So with the code below how would I go about
getting 1 email at a time and deleting it.  Logging
out and looping back to login until all emails are
read?

Or is there another way around it, by looping over the
email lookup each time in the $body?

Any suggestions?

echo "Email: " . $email . " ";

Displays the email output as it's grabbed from the
codena d$email is defined in a mysql query.  So on an
attempt to grab more than 1 email at a time only
returns the last emails from: address rather than
grabbing all emails listed in the $body of the email.

So it appears to not find multiple email addresses in
multiple emails.  How could I get it to look and
output each entry correctly?

----code-----

<?php
 
include("../db/connectionstart.php");

global $IP_RegExp_Match, $Host_RegExp_Match,
$Email_RegExp_Match;
$IP_RegExp_Match =
'\\[?[0-9]{1,3}(\\.[0-9]{1,3}){3}\\]?';
$Host_RegExp_Match = '(' . $IP_RegExp_Match .
    '|[0-9a-z]([-.]?[0-9a-z])*\\.[a-z][a-z]+)';
$Email_RegExp_Match = '[0-9a-z]([-_.+]?[0-9a-z])*(%'
. $Host_RegExp_Match .
    ')?@' . $Host_RegExp_Match;


$user = 'whatever';
$pass = 'whenever';

$MAILSERVER =
"{mail.yourpop3servergoeshere.com:110/pop3/notls}";
//Para POP3

$mbox = @imap_open ($MAILSERVER,$user,$pass) or die
("Sorry can't connect -
please check your settings");

$check = imap_mailboxmsginfo($mbox);
echo "Messages before delete: " . $check->Nmsgs .
"<br />\n";

$headers = imap_headers($mbox);

if ($headers == false) {
   echo "There are no messages to be deleted.<br
/>\n";
} else {
   while (list ($key, $val) = each ($headers)) {


   for ($i = 1; $i <= imap_num_msg($mbox); $i++)
{
   $header = imap_headerinfo($mbox, $i, 80, 80);
   $messageBody = imap_body($mbox, $i);

$messageBody = strip_tags($messageBody,
'<a><b><i><u>');
$messageBody = str_replace("\'", "", $messageBody);
$messageBody = str_replace("\\", "", $messageBody);
$messageBody = str_replace("\"", "", $messageBody);
$messageBody = str_replace("3D", "", $messageBody);

    global $color, $Email_RegExp_Match;
    $sbody     = $messageBody;
    $addresses = array();

    /* Find all the email addresses in the body */
    while(eregi($Email_RegExp_Match, $sbody, $regs))
{
        $addresses[$regs[0]] = $regs[0];
        $start = strpos($sbody, $regs[0]) +
strlen($regs[0]);
        $sbody = substr($sbody, $start);
    }
    /* Replace each email address with a compose URL
*/
    foreach ($addresses as $email) {
        $body = str_replace($email, $comp_uri,
$body);
   mysql_query ("DELETE FROM emaillist WHERE
EMail='$email'");

};

imap_delete($mbox, 1);
$check = imap_mailboxmsginfo($mbox);
imap_expunge($mbox);
$check = imap_mailboxmsginfo($mbox);

    };

}};

$check = imap_mailboxmsginfo($mbox);
echo "Messages after delete: " . $check->Nmsgs .
"<br />\n";
echo "Email: " . $email . " ";


imap_close($mbox);
?>



http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to