From: npeelman at cfl dot rr dot com Operating system: Windows PHP version: 4.4.0 PHP Bug Type: IMAP related Bug description: IMAP uid and message number confusion
Description: ------------ IMAP_UID does not return correct information. In relation to bugs (7486, 10850, 12954) which seem to be several years old, as of PHP4.3.4RC3-dev (I am developing GTK apps and this is the supplied version), also tested with PHP5.0.2: There appears to be confusion as to the difference between 'Message No#' and 'Message-Id'. Message No# is a temporary number and can change as messages are deleted and added. As an example: you have messages numbering from 1 - 5 and you delete number 3. You will now have a new number 3 and no number 5 as 4 becomes 3 and 5 becomes 4. Message-Id is a unique id generated by the server and does not change over time. Technically speaking, no two messages generated from the same server should ever have the same Message-Id. This is stored withing the message headers. Message No# is more of a general (read loose) pointer where-as Message-Id is more of a direct pointer to a specific message. This appears to be a multi-part problem: #1 imap_uid($imap_stream, $msg_no) returns (as an INT) the 'Message No#' as defined above. This is conflicting with the very definition of this command. We already know the Message No# as it is a required parameter to this function. #2 The 'Message-Id' as defined in RFC822 is a STRING (possibly containing more than just numbers), not an INT. This automatically breaks 'imap_msgno($imap_stream, $uid), 'imap_body', and any other function that can accept Message-Id, as $uid is expected to be an INT by these functions, but is not. #3 The following snippet will retrieve the Message-Id (uid) from the message $msg_no (Message No# as defined above) if it is present: $header = imap_headerinfo($imap_stream, $msg_no); return $header->message_id; This returns a STRING as defined in RFC822 but is unusable by functions stated in #2 above. Excerpt from BUG: #7486 [27 Oct 2000 3:30am CEST] rick at alpinenetworking dot com When I call connect to a qmail pop server and call imap_uid all it does is return the message number back to me. It DOES NOT return the uid. I have to call imap_header for that and it is very slow. [3 May 2001 3:36pm CEST] [EMAIL PROTECTED] You might have the wrong idea of what uid is - what do you expect it to be? On pop servers the message uid will very likely just _be_ the message number... [3 May 2001 5:14pm CEST] [EMAIL PROTECTED] From: "Rick Gigger" <[EMAIL PROTECTED]> All email messages have a unique identifier. It is a long string that ususally contains a domiain name or ip address. It is unique to all email addresses in the world. It would be much, much more useful if imap_uid would return that instead. [3 May 2001 5:16pm CEST] [EMAIL PROTECTED] That's the Message-ID header. The uid which imap_uid() is intended to return is a unique identifier of that that message in that mailbox that won't change over time. It has nothing to do with the Message-ID header. --- As per this last message by [EMAIL PROTECTED]: Huh? The Message-Id header IS the one that won't change over time, this entry contradicts itself and it IS the one that imap_uid should be intending to return. A thought to back this up is that you don't really need a function to determine a Message No# but you do need one to determine the Message-Id. Reproduce code: --------------- $imap = imap_open($mailbox,$user,$password); $num_msgs = imap_num_msg($imap); for ($loop = 1; $loop <= $num_msgs; $loop++) { $uid = imap_uid($imap, $loop); echo "Message: $loop -> $uid \n\r"; $header = imap_headerinfo($this->imap, $loop); echo "Msg UID: $loop -> $header->message_id \n\r"; $body = imap_body($imap, $uid, FT_UID); echo "Msg body: \n\r $body \n\r\n\r"; } Expected result: ---------------- For $num_msgs = 1: Message: 1 -> <[EMAIL PROTECTED]> Msg UID: 1 -> <[EMAIL PROTECTED]> Msg body: Message body here... Actual result: -------------- For $num_msgs = 1: Message: 1 -> 1 Msg UID: 1 -> <[EMAIL PROTECTED]> Msg body: Warning: imap_body(): Bad message number in path:\to\source.php on line # (line containing imap_body() function) -- Edit bug report at http://bugs.php.net/?id=34289&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34289&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34289&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34289&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34289&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34289&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34289&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34289&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34289&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34289&r=support Expected behavior: http://bugs.php.net/fix.php?id=34289&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34289&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34289&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34289&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34289&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34289&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34289&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34289&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34289&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34289&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34289&r=mysqlcfg