mail_get_thread
List the messages in the same conversation as a given email, across its folder, INBOX and Sent, oldest first. Use to see the back-and-forth before replying.
Instructions
List the messages in the same conversation as a given message, found in its folder, INBOX and Sent, oldest first, as summaries without bodies.
Use when: you need the back-and-forth around a message before replying or summarising. Not for reading bodies (use mail_get_messages or mail_get_message) or for finding mail by subject (use mail_search_messages). Parameters:
folder is where the uid lives: an alias (INBOX, Sent, Drafts, Trash, Junk, Archive; case-insensitive) or a name copied exactly from mail_list_folders. INBOX and Sent are searched whatever you pass.
uid is an integer valid only in that folder, from mail_search_messages, mail_list_changes, mail_list_senders (latest_uid), mail_list_awaiting_reply (its Sent folder) or a summary of an earlier thread (use that summary's own folder).
uidvalidity comes from the same result as the uid. Passed, a renumbered folder is refused instead of threading the wrong message; omitted, that check is skipped. Only the given folder is checked; INBOX and Sent are read as they are now. Behavior:
read-only; reads the message's threading headers, then finds messages whose Message-ID is the thread root or whose References contain it.
Messages filed in other folders are not found.
Copies in several folders are merged by Message-ID. Returns: {root_message_id, count, messages}.
Each summary carries its own folder and uidvalidity, so read bodies with mail_get_messages one folder at a time.
A message without threading headers gives root_message_id null, only that message and no count. Errors:
'No message with uid' or 'uids are out of date': search again.
'Could not open the folder' or 'Could not locate the folder' for an alias the account lacks: check mail_list_folders.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | Message uid in that folder (from mail_search_messages). | |
| folder | Yes | Mail folder, e.g. INBOX, Sent, Archive or a custom name. | |
| uidvalidity | No | The 'uidvalidity' from the result the uid came from: a renumbered folder is then refused, not misread. |