+
+ /** returns "true" if the copy was completed successfully.
+ ** returns "false" with an error message if unsuccessful.
+ **/
+ function copyMessages($imapConnection, $from_id, $to_id, $folder) {
+ fputs($imapConnection, "mailboxStore COPY $from_id:$to_id \"$folder\"\n");
+ $read = fgets($imapConnection, 1024);
+ while ((substr($read, 0, 15) != "mailboxStore OK") && (substr($read, 0, 15) != "mailboxStore NO")) {
+ $read = fgets($imapConnection, 1024);
+ }
+
+ if (substr($read, 0, 15) == "mailboxStore NO") {
+ echo "ERROR... $read<BR>";
+ return false;
+ } else if (substr($read, 0, 15) == "mailboxStore OK") {
+ return true;
+ }
+
+ echo "UNKNOWN ERROR copying messages $from_id to $to_id to folder $folder.<BR>";
+ return false;
+ }