SSilence / php-imap-client

a easy solution for simple IMAP email access in php
MIT License
268 stars 136 forks source link

setUnseenMessage() true or false does the same thing #168

Open abdullahseba opened 7 years ago

abdullahseba commented 7 years ago

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

mattparksjr commented 7 years ago

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

mattparksjr commented 7 years ago

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

abdullahseba commented 7 years ago

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

mattparksjr commented 7 years ago

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 commented 7 years ago

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

abdullahseba commented 7 years ago

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

mattparksjr commented 7 years ago

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 :)

abdullahseba commented 7 years ago

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

mattparksjr commented 7 years ago

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

sergey144010 commented 7 years ago
  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.
MasterAlchemist commented 6 years ago

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");
    }
mattparksjr commented 6 years ago

I will deff check this out.