I am working on my php code to mark my email as read or seen. I understand that there is alot of answers out there, I have did alot of google search and I have tried to use each different codes, but unfortunately it did not work for me. It will not mark my email as read or seen when I tried to use each different codes. It can only mark my emails as Unread or not seen when I use imap_clearflag_full($inbox, $email_number, "\\Seen");
.
Here is what I have already tried so far:
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");
And I have already tried this:
imap_clearflag_full($inbox, $email_number, "\\Seen", ST_UID);
Here is the full code:
<?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);
?>
What I expect to do is to mark my emails as read or seen. I have tried everything and I don't know what to do.
Can you please show me an example code how I could mark my emails as read or seen?
Thank you.