php-imap-client icon indicating copy to clipboard operation
php-imap-client copied to clipboard

setUnseenMessage() true or false does the same thing

Open abdullahseba opened this issue 8 years ago • 12 comments

Hi $imap->setUnseenMessage(1, $seen = true); and $imap->setUnseenMessage(1, $seen = false); sets the message as unread. Also whats the difference between id and uid? This dont seem to work with uid's

abdullahseba avatar May 24 '17 09:05 abdullahseba

You must use the id. UID and IDS are both used differently by php. Fixing this now..

mattparksjr avatar May 24 '17 11:05 mattparksjr

setUnseenMessage ONLY can set the message as seen. It cannot set the unseen flag according to here and here.

mattparksjr avatar May 24 '17 11:05 mattparksjr

Why does it require the boolean value than? There should be a setSeenMessage() than. But personal I would prefer one method that did both.

abdullahseba avatar May 24 '17 11:05 abdullahseba

It does not require the boolean. The docs are incorrect which I will fix. We cannot set a message as seen as you can read above. The only way I can think to read a message without the stay unread modifier we apply. What do you think?

mattparksjr avatar May 24 '17 11:05 mattparksjr

Also setUnseenMessage would be renamed if it had two functions. How about setMessageSeenState?

mattparksjr avatar May 24 '17 11:05 mattparksjr

setUnseenMessage Is perfect. I'm haven't got much programming experience so cant comment on how its done. Only 17 :)

abdullahseba avatar May 24 '17 11:05 abdullahseba

Well let's not go into age here :) (Just know im wayy younger than you think. Younger than you.. ) Anyways I think that way will work. I will begin testing this and ill commit it later :)

mattparksjr avatar May 24 '17 12:05 mattparksjr

Ah but I'm a nub too. just started PHP this year :)

abdullahseba avatar May 24 '17 13:05 abdullahseba

Ah :) Started about 2 :). Anyhow my method seems to be the best I can find

mattparksjr avatar May 24 '17 13:05 mattparksjr

  1. This method setUnseenMessage($ids) is a wrapper for this imap_clearflag_full(). So he returns boolean. More details here http://php.net/manual/en/function.imap-clearflag-full.php

Return Values Returns TRUE on success or FALSE on failure.


    /**
     * Delete flag message SEEN
     *
     * @param int $ids or string like 1,2,3,4,5 or string like 1:5
     * @return bool
     */
    public function setUnseenMessage($ids)
    {
        // We need better docs for this
        return imap_clearflag_full($this->imap, $ids, "\\Seen");   
    }
  1. About ID and UID.

You have an INBOX folder on the mail server. When a message arrives there, it is marked as ID = 1 and UID = unikid9238, when the next letter comes it is marked as ID = 1 and UID = unicid9239, and the previous letter is changed to ID = 2. Thus, the ID of the letter in the current folder is CHANGED, and the letter UID in the current folder is NOT CHANGED. BUT when moving a letter from a folder such as INBOX to a folder for example SENT, it changes both the ID and the UID.

Now the given library allows to work correctly only with the ID.

This library is a wrapper over standard built-in functions in PHP. You can see it here. http://php.net/manual/en/book.imap.php

  1. Well, you have everything ahead of you. Study the protocols of interaction between servers and clients, for example imap-server and the php. Read more php.net, and everything will be ok.

sergey144010 avatar May 24 '17 19:05 sergey144010

Hi, to mark as seen email you should try imap_setflag_full, I'm a newbie in programing, and I don't speak English. I added the second function and works for me!

 public function setUnseenMessage($ids)
    {
        // We need better docs for this
        return imap_clearflag_full($this->imap, $ids, "\\Seen");   
    }
    
    public function setReadMessage($ids)
    {
        return imap_setflag_full($this->imap, $ids, "\\Seen");
    }

MasterAlchemist avatar Apr 09 '18 23:04 MasterAlchemist

I will deff check this out.

mattparksjr avatar Apr 10 '18 15:04 mattparksjr