imap_append_basic.phpt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Test imap_append() function : basic functionality
  3. --EXTENSIONS--
  4. imap
  5. --SKIPIF--
  6. <?php
  7. require_once(__DIR__. '/setup/skipif.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. echo "*** Testing imap_append() : basic functionality ***\n";
  12. require_once(__DIR__. '/setup/imap_include.inc');
  13. echo "Create a new mailbox for test\n";
  14. $imap_stream = setup_test_mailbox("imapappendbaisc", 0);
  15. $mb_details = imap_mailboxmsginfo($imap_stream);
  16. echo "Add a couple of msgs to the new mailbox\n";
  17. var_dump(imap_append($imap_stream, $mb_details->Mailbox
  18. , "From: webmaster@something.com\r\n"
  19. . "To: info@something.com\r\n"
  20. . "Subject: Test message\r\n"
  21. . "\r\n"
  22. . "this is a test message, please ignore\r\n"
  23. ));
  24. var_dump(imap_append($imap_stream, $mb_details->Mailbox
  25. , "From: webmaster@something.com\r\n"
  26. . "To: info@something.com\r\n"
  27. . "Subject: Another test\r\n"
  28. . "\r\n"
  29. . "this is another test message, please ignore it too!!\r\n"
  30. ));
  31. $check = imap_check($imap_stream);
  32. echo "Msg Count after append : ". $check->Nmsgs . "\n";
  33. echo "List the msg headers\n";
  34. var_dump(imap_headers($imap_stream));
  35. imap_close($imap_stream);
  36. ?>
  37. --CLEAN--
  38. <?php
  39. $mailbox_suffix = 'imapappendbaisc';
  40. require_once(__DIR__ . '/setup/clean.inc');
  41. ?>
  42. --EXPECTF--
  43. *** Testing imap_append() : basic functionality ***
  44. Create a new mailbox for test
  45. Create a temporary mailbox and add 0 msgs
  46. New mailbox created
  47. Add a couple of msgs to the new mailbox
  48. bool(true)
  49. bool(true)
  50. Msg Count after append : 2
  51. List the msg headers
  52. array(2) {
  53. [0]=>
  54. string(%d) "%w%s 1)%s webmaster@something. Test message (%d chars)"
  55. [1]=>
  56. string(%d) "%w%s 2)%s webmaster@something. Another test (%d chars)"
  57. }