简体   繁体   English

在 PHP IMAP 中标记电子邮件未读

[英]Marking an email unread in PHP IMAP

Are there any PHP IMAP functions which can be used to mark an email as unread?是否有任何PHP IMAP函数可用于将电子邮件标记为未读? I am checking the mail using some IMAP functions that return the messages as read, but I want to make them unread.我正在使用一些 IMAP 函数检查邮件,这些函数将消息返回为已读,但我想让它们未读。

To mark an email message as unread, you should unset the \\\\Seen flag on that message.要将电子邮件标记为未读,您应该取消设置该邮件上的\\\\Seen标志。
You could use theimap_clearflag_full function to clear message flags.您可以使用imap_clearflag_full函数来清除消息标志。

// Unset desired flag
imap_clearflag_full($imap_connection, $message_number, "\\Seen");
// Confirm changes
imap_close($imap_connection, CL_EXPUNGE);

Note:笔记:

"I am checking the mail using some IMAP functions that return the messages as read" “我正在使用一些 IMAP 函数检查邮件,这些函数将消息返回为已读”

You can set the FT_PEEK flag when reading messages, this will not set the \\\\Seen flag if not already set.您可以在阅读消息时设置FT_PEEK标志,如果尚未设置,则不会设置\\\\Seen标志。

// This will not mark a message as seen
$body = imap_body($imap_stream, $msg_number, FT_PEEK); 

试试imap_clearflag_full

imap_clearflag_full($mailbox, $email_number, "\\Seen");

试试 imap_setflag_full, http: //www.php.net/manual/en/function.imap-setflag-full.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM