首页 > 解决方案 > 如何在 php 中将我的电子邮件标记为已读或已查看?

问题描述

我正在编写我的 php 代码以将我的电子邮件标记为已读或已查看。我知道那里有很多答案,我做了很多谷歌搜索,我尝试使用每个不同的代码,但不幸的是它对我不起作用。当我尝试使用每个不同的代码时,它不会将我的电子邮件标记为已读或已查看。它只能在我使用时将我的电子邮件标记为未读或未查看imap_clearflag_full($inbox, $email_number, "\\Seen");

这是我到目前为止已经尝试过的:

imap_clearflag_full($inbox, $email_number, "\\Seen");
imap_clearflag_full($inbox, $email_number, "\\UnSeen");
imap_clearflag_full($inbox, $email_number, "\\UNSEEN");
imap_clearflag_full($inbox, $email_number, "\\Seen \\Recent");

我已经尝试过这个:

imap_clearflag_full($inbox, $email_number, "\\Seen", ST_UID);

这是完整的代码:

<?php
require_once "Mail.php";
require_once('Mail/IMAPv2.php');

$username = 'myusername';
$password = 'mypassword';
$mailbox = '{imap.example.com:993/imap/ssl/novalidate-cert}INBOX';
$email_number= '236';

$inbox = imap_open($mailbox, $username, $password) or die("Can't connect: " . imap_last_error());

if (PEAR::isError($inbox)) {
    echo "<span style='font-weight: bold;'>Error:</span> Unable to build a connection.";
}
else
{
    imap_clearflag_full($inbox, $email_number, "\\Seen \\Recent");
    echo "mailbox have been marked as read";
}
imap_expunge($inbox);
imap_close($inbox);
?>

我期望做的是将我的电子邮件标记为已读或已查看。我已经尝试了一切,我不知道该怎么做。

您能否向我展示一个示例代码,如何将我的电子邮件标记为已读或已查看?

谢谢你。

标签: phpemailimap

解决方案


推荐阅读