imap_open将电子邮件复制到文件夹,然后删除电子邮件

时间:2014-01-01 14:45:34

标签: php

我正在使用PHP函数imap_open

循环显示电子邮件

每封电子邮件的循环完成后,如何将其移动或复制到特定文件夹然后将其删除?

这是我的代码:

//try to connect
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect: ' . imap_last_error());
//grab emails
$emails = imap_search($inbox,'ALL');

//if emails are returned, cycle through each...
if($emails) {
    //begin output var
    $output = '';

    //put the newest emails on top
    rsort($emails);

    //for every email...
    foreach($emails as $email_number) {
    //run queries etc here
    }
}

目前我只是使用以下方式删除电子邮件:

//delete the email
//this deletes the email
imap_delete($inbox,1);
//this bit really really deletes the email
imap_expunge($inbox);

0 个答案:

没有答案