--TEST-- Test mail() function : basic functionality --SKIPIF-- --INI-- max_execution_time = 120 --FILE-- 0) { // sleep for a while to allow msg to be delivered sleep(1); $current_msg_count = imap_check($imap_stream)->Nmsgs; // Iterate over recent msgs to find the one we sent above for ($i = 1; $i <= $current_msg_count; $i++) { // get hdr details $hdr = imap_headerinfo($imap_stream, $i); if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { echo "Id of msg just sent is $i\n"; echo ".. delete it\n"; imap_delete($imap_stream, $i); $found = true; break; } } $repeat_count -= 1; } if (!$found) { echo "TEST FAILED: email not delivered\n"; } else { echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); ?> ===Done=== --EXPECTF-- *** Testing mail() : basic functionality *** Msg sent OK Id of msg just sent is %d .. delete it TEST PASSED: Msgs sent and deleted OK ===Done===