에서 이메일을 삭제하지 그것은 이메일 계정을 확인하고 MySQL 데이터베이스에 메시지를 다운로드 여기PHP 이메일 나는 PHP 클래스의 etodb를 사용하고 서버
http://www.phpclasses.org/package/3324-PHP-Retrieve-e-mail-messages-into-a-MySQL-database.html
발견했다. 그것은 완벽하게 작동하지만 각 루프가 끝날 때 (받은 편지함의 각 메일에 대해 반복) 이메일을 삭제합니다. 이메일을 삭제하지 못하게하는 방법을 알고 있지만 메시지를 삭제하거나받은 편지함이 완전히 비어 있지 않은 한 스크립트가 새 이메일을 데이터베이스에 삽입하지 못하게하는 몇 가지 이유가 있습니다.
여기는 위에서 언급 한 php 클래스의 끝 부분입니다. 이 섹션에서는 각 메시지를 반복하여 데이터베이스에 삽입하고 설정하면 메시지를 삭제합니다. 요약하면 제 질문은 메시지를 삭제하거나 빈받은 편지함이 없어도 스크립트가 올바르게 작동하도록하는 것입니다.
$total_messages = $this->num_message();
// IM ASSUMING THIS FOR LOOP IS NOT LOOPING MESSAGES CORRECTLY
for ($i = 0; $i < $total_messages; $i++) {
#Get first message
$email = $this->email_get();
$ismsgdb = $this->db_add_message($email); // THIS INSERTS EACH MSG INTO DATABASE
#Get store dir
$dir = $this->dir_name();
$id_log = $this->add_db_log($email, 'Copy e-mail - start ');
foreach($this->partsarray as $part){
if($part[text][type] == 'HTML'){
#$message_HTML = $part[text][string];
$this->db_update_message($part[text][string], $type= 'HTML');
}elseif($part[text][type] == 'PLAIN'){
$message_PLAIN = $part[text][string];
$this->db_update_message($part[text][string], $type= 'PLAIN');
}elseif($part[attachment]){
#Save files(attachments) on local disc
// $message_ATTACH[] = $part[attachment];
foreach(array($part[attachment]) as $attach){
$attach[filename] = $this->mimie_text_decode($attach[filename]);
$attach[filename] = preg_replace('/[^a-z0-9_\-\.]/i', '_', $attach[filename]);
$this->add_db_log($email, 'Start coping file:"'.strip_tags($attach[filename]).'"');
$this->save_files($this->newid.$attach[filename], $attach[string]);
$filename = $dir.$this->newid.$attach[filename];
$this->db_add_attach($attach[filename], $filename);
$this->update_db_log('<b>'.$filename.'</b>Finish coping: "'.strip_tags($attach[filename]).'"', $this->logid);
}
//
}elseif($part[image]){
#Save files(attachments) on local disc
$message_IMAGE[] = $part[image];
foreach($message_IMAGE as $image){
$image[filename] = $this->mimie_text_decode($image[filename]);
$image[filename] = preg_replace('/[^a-z0-9_\-\.]/i', '_', $image[filename]);
$this->add_db_log($email, 'Start coping file: "'.strip_tags($image[filename]).'"');
$this->save_files($this->newid.$image[filename], $image[string]);
$filename = $dir.$this->newid.$image[filename];
$this->db_add_attach($image[filename], $filename);
$this->update_db_log('<b>'.$filename.'</b>Finish coping:"'.strip_tags($image[filename]).'"', $this->logid);
}
}
}
$this->spam_detect();
$this->email_setflag();
$this->email_delete(); // WHEN I REMOVE THIS THE SCRIPT WONT GRAB NEW EMAILS
$this->email_expunge(); // WHEN I REMOVE THIS THE SCRIPT WONT GRAB NEW EMAILS
$this->update_db_log('Finish coping', $id_log);
}
감사합니다! 나는 그것이 당신의 해결책이 내 문제를 해결했다는 것을 알게되었습니다. –