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