I am developing a small webmail application, what i need to do is thread the emails like what Gmail does .
I planned on achieving it by getting 'references
' of a mail (using uid
) and then showing them as one thread. I get the references like this:
$inbox = imap_open("{imap.example.org:143}INBOX", "username", "password");
$email_number = imap_msgno($inbox,$uid);
$overview = imap_fetch_overview($inbox,$email_number,0);
$mess = $overview[0];
$refs = array_filter(explode(' ', htmlentities($mess->references)));
The $refs
array is an array of Message-Id's
, can anyone tell me how to fetch a mail based on a Message-Id
.
If i can get a Message UID
or Message Sequence Number
from a Message-Id
that also would suffice.
An alternative that came up in my mind was to achieve this is by using imap_search()
for searching mails with same subject(after stripping 'Re:' from it etc) but i don't think it would be ideal.
Can anyone give me helpful pointers as to how to solve this? Thanks in advance
SEARCH HEADER Message-ID string
? – Plunge