【问题标题】:How do I move an email to a different folder using zend_mail and zend_mail_storage_imap?如何使用 zend_mail 和 zend_mail_storage_imap 将电子邮件移动到不同的文件夹?
【发布时间】:2011-04-30 21:51:48
【问题描述】:

我正在将这些库用于我正在构建的电子邮件应用程序。

$storage = new Zend_Mail_Storage_Imap($imap);

if (strpos($storage->getMessage($i),'chocolate') !== FALSE ) 

{
        //Move to chocolate folder here
}

另外,有没有办法让这个发件人收到的电子邮件从现在开始自动进入巧克力文件夹? ...类似于在 gmail 中构建标签的方式,来自该发件人的所有邮件将来都会自动进入该文件夹。

我还是 zend 的新手,我将再次重新查看文档。

【问题讨论】:

    标签: php zend-framework email zend-mail


    【解决方案1】:

    这有点棘手是真的。

    $storage = new Zend_Mail_Storage_Imap($imap);
    if (strpos($storage->getMessage($i),'chocolate') !== FALSE ){
        //Move to chocolate folder here
        $messageUniqueId = $storage->getUniqueId($i);
        $currentMessageId = $storage->getNumberByUniqueId($messageUniqueId);
        $storage->moveMessage($messageUniqueId, 'chocolate');
    }
    

    【讨论】:

    • 仅供参考:如果您直接在 moveMessage 中使用 $i,它可能会起作用。但是,如果应该删除第二条消息并且 $i 来自循环,那么 id 可能是错误的。因此,您必须使用通过 Elzo 代码获得的当前 ID。
    • Barney 删除了我的编辑:我认为最后一行应该是 $storage->moveMessage($currentMessageId, 'chocolate');我只是用唯一的 id 和 gmail 尝试了它,但没有用。查看 Zend_Mail_Storage_Imap->getNumberByUniqueId($id) 的注释。还是 $currentMessageId 只是为了装饰?假设 Zend 1.12。
    猜你喜欢
    • 2019-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-20
    • 2012-11-21
    • 2019-09-21
    • 2011-11-25
    • 1970-01-01
    相关资源
    最近更新 更多