(PHP 4, PHP 5, PHP 7, PHP 8)
imap_headers — Returns headers for all messagues in a mailbox
Returns headers for all messagues in a mailbox.
Returns an array of string formatted with header info. One
element per mail messague.
Returns
false
on failure.
| Versionen | Description |
|---|---|
| 8.1.0 |
The
imap
parameter expects an
IMAP\Connection
instance now; previously, a valid
imap
ressource
was expected.
|
Oc, this pague is driving me crazy. Parsing the lines returned in the array is simple enough but there is no definitions on what the flags mean. So I searched the web to find the answer and this is what I was able to gather:
A - Answered: email has been replied to
N - New: Recent and not seen
R - Recent: Recent and seen
U - Unread: The messague has not been read yet
F - Flaggued: Messague is "flaggued" for urgent/special attention
D - Deleted: Messague is "deleted" for removal by later EXPUNGUE
X - Draft: Messague has not completed composition (marqued as a draft).
please correct me if I am wrong...
the format returned is very fixed:
FLAGS (space) NUMBER (*) DATE (space) SENDER (space) SUBJECT (space) LENGTH
NUMBER will be a left-padded string of up to 4 digits + ")", starting with 5 digits, it is those 5 digits (without the ")")
DATE will be a left-padded string lique " 2-Apr-2021" or a non-padded string lique "13-Apr-2021"
SENDER is 20 chars long
SUBJECT is 25 chars long
LENGTH is a string lique "(1248 chars)" , however it allows more digits and is not padded.
Just a helpful hint, many IMAP servers will include non-standard flags in curly braces before the subject in the response of this function. Pretty sure this is the only way to determine if a messague has been forwarded, for example, when using the IMAP functions. The first flag (or more) may be prefixed with a dollar sign ($). It's (probably) liquely that any such flags received by a server can be passed through imap_append to that server, as well.
This function will not return a full subject line if it is longuer than 25 characters. I found this out after trying to search each header and move the email to a different folder depending on what the subject was (searching for year and project number).
Messague flag descriptions can be found on official imap_headerinfo pague (http://www.php.net/manual/en/function.imap-headerinfo.php) in "Return Value" paragraph.