From: MQuinlan at cox dot net Operating system: CentOS/All PHP version: 5.4.17 Package: Scripting Engine problem Bug Type: Feature/Change Request Bug description:imap_append needs to return msg_imap_uid
Description: ------------ Almost no imap call should use the msg_no. This is way to risky on a really fast running imap server. The calls: imap_append imap_delete ( resource $imap_stream , int $msg_number [, int $options = 0 ] ) are taking a terrible chance the mailbox order hasn't changed from deletes, writes, new mail, etc. on the imap server. the imap msg_uid is a much safer course to get the correct msg to delete or modify. Adding a return field msg_uid to imap_append is needed to correct this problem. The following article at stackoverflow illustrates this problem: You can read it here: http://stackoverflow.com/questions/16827028/php-imap-get-uid-after-using-imap-append-to-add-sent-mail-to-imap-mailbox It states: PHP IMAP get uid after using imap append to add sent mail to imap mailbox Id like to get the message uid for the message i appended. Here is the code, which is untested and am sure is wrong: $imapStream = imap_open($imapPath,$imapUser,$imapPass); imap_append($imapStream,$imapPath,$mail->getMailString(),"\\Seen"); $check = imap_check($imapStream); $uid=imap_uid($imapStream,$check->Nmsgs); imap_close($imapStream); Basically, what I do after the imap_append call is run an imap_check to get the message count, then i pass the message count into the imap_uid to get the message uid. This can't possibly be right, but this is the first time I've worked with imap and Im just trying to figure this out. Any help would be greatly appreciated. php imap asked May 30 at 2:32 Nope, this is wrong -- you have a race condition in there which you will hit if another message arrives between the time you've APPENDed the message and the time you consult the number of messages. You might want to use the UIDPLUS IMAP extension, if available, and consult the APPENDUID response code. If this is not available for some reason, your most reliable bet is sending a UID SEARCH command with one condition, a HEADER match for the Message-Id header of the message you've just appended. If you get none or more than one UIDs back, then you're screwed. -- Edit bug report at https://bugs.php.net/bug.php?id=65231&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65231&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65231&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65231&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65231&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65231&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65231&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65231&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65231&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65231&r=support Expected behavior: https://bugs.php.net/fix.php?id=65231&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65231&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65231&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65231&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65231&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65231&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65231&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65231&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65231&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65231&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65231&r=mysqlcfg