Exemplo n.º 1
0
<?php

require_once dirname(__FILE__) . '/imap_include.inc';
$stream_id = setup_test_mailbox('', 1);
imap_delete($stream_id, 1);
var_dump(imap_undelete($stream_id, 1));
imap_close($stream_id);
require_once 'clean.inc';
<?php

/* Prototype  : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
 * Description: Read an overview of the information in the headers 
 * of the given message sequence 
 * Source code: ext/imap/php_imap.c
 */
/*
 * Pass different sequences/msg numbers as $msg_no argument to test behaviour
 * of imap_fetch_overview()
 */
echo "*** Testing imap_fetch_overview() : usage variations ***\n";
require_once dirname(__FILE__) . '/imap_include.inc';
$stream_id = setup_test_mailbox('', 3, $mailbox, 'notSimple');
// set up temp mailbox with 3 msgs
$sequences = array(0, 4, '4', '2', '1,3', '1, 2', '1:3');
// pass uid without setting FT_UID option
foreach ($sequences as $msg_no) {
    echo "\n-- \$msg_no is {$msg_no} --\n";
    $overview = imap_fetch_overview($stream_id, $msg_no);
    if (!$overview) {
        echo imap_last_error() . "\n";
    } else {
        foreach ($overview as $ov) {
            echo "\n";
            displayOverviewFields($ov);
        }
    }
}
// clear error stack
imap_errors();
<?php

/* Prototype  : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
 * Description: Read an overview of the information in the headers of the given message sequence 
 * Source code: ext/imap/php_imap.c
 */
/*
 * Pass a multipart message to imap_fetch_overview() to test the contents of returned array
 */
echo "*** Testing imap_fetch_overview() : usage variations ***\n";
require_once dirname(__FILE__) . '/imap_include.inc';
$stream_id = setup_test_mailbox('', 0, $mailbox);
// setup temp mailbox
create_multipart_message($stream_id, $mailbox);
// refresh msg numbers
imap_check($stream_id);
$msg_no = 1;
$a = imap_fetch_overview($stream_id, $msg_no);
echo "\n--> Object #1\n";
displayOverviewFields($a[0]);
/**
 * Create a multipart message with subparts
 *
 * @param resource $imap_stream
 * @param string $mailbox
 */
function create_multipart_message($imap_stream, $mailbox)
{
    global $users, $domain;
    $envelope["from"] = "*****@*****.**";
    $envelope["to"] = "{$users['0']}@{$domain}";
Exemplo n.º 4
0
<?php

/* Prototype  : bool imap_mail_copy  ( resource $imap_stream  , string $msglist  , string $mailbox  [, int $options = 0  ] )
 * Description: Copies mail messages specified by msglist  to specified mailbox. 
 * Source code: ext/imap/php_imap.c
 */
echo "*** Testing imap_mail_copy() : basic functionality ***\n";
require_once dirname(__FILE__) . '/imap_include.inc';
echo "Create a new mailbox for test\n";
$imap_stream = setup_test_mailbox("", 1);
if (!is_resource($imap_stream)) {
    exit("TEST FAILED: Unable to create test mailbox\n");
}
$check = imap_check($imap_stream);
echo "Msg Count in new mailbox: " . $check->Nmsgs . "\n";
var_dump(imap_mail_copy($imap_stream, '1', 'INBOX.' . $mailbox_prefix));
imap_close($imap_stream);
?>
===Done===
<?php 
require_once 'clean.inc';
Exemplo n.º 5
0
<?php

/* Prototype  : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
 * Description: Get the full unfiltered header for a message 
 * Source code: ext/imap/php_imap.c
 */
echo "*** Testing imap_fetchheader() : basic functionality ***\n";
require_once dirname(__FILE__) . '/imap_include.inc';
// Initialise all required variables
$stream_id = setup_test_mailbox('', 1, $mailbox, 'multiPart');
// setup temp mailbox with 1 msg
$msg_no = 1;
$options = array('FT_UID' => FT_UID, 'FT_INTERNAL' => FT_INTERNAL, 'FT_PREFETCHTEXT' => FT_PREFETCHTEXT);
// Calling imap_fetchheader() with all possible arguments
echo "\n-- All possible arguments --\n";
foreach ($options as $key => $option) {
    echo "-- Option is {$key} --\n";
    if ($key == 'FT_UID') {
        $msg_uid = imap_uid($stream_id, $msg_no);
        var_dump(imap_fetchheader($stream_id, $msg_uid, $option));
    } else {
        var_dump(imap_fetchheader($stream_id, $msg_no, $option));
    }
}
// Calling imap_fetchheader() with mandatory arguments
echo "\n-- Mandatory arguments --\n";
var_dump(imap_fetchheader($stream_id, $msg_no));
?>
===DONE===
<?php 
require_once dirname(__FILE__) . '/clean.inc';
Exemplo n.º 6
0
<?php

/* Prototype  : object imap_bodystruct  ( resource $imap_stream  , int $msg_number  , string $section  )
 * Description: Read the structure of a specified body section of a specific message.
 * Source code: ext/imap/php_imap.c
 */
echo "*** Testing string imap_bodystruct : basic functionality ***\n";
require_once dirname(__FILE__) . '/imap_include.inc';
echo "Create a new mailbox for test and add a multipart msgs\n";
$imap_stream = setup_test_mailbox("", 1, $mailbox, "multipart");
if (!is_resource($imap_stream)) {
    exit("TEST FAILED: Unable to create test mailbox\n");
}
echo "\nGet and validate structure of body part 1\n";
$m = imap_bodystruct($imap_stream, 1, "1");
$mandatoryFields = array('ifsubtype', 'ifdescription', 'ifid', 'ifdisposition', 'ifdparameters', 'ifparameters');
foreach ($mandatoryFields as $mf) {
    if (isValid($m->{$mf})) {
        echo "{$mf} is 0 or 1\n";
    } else {
        echo "{$mf} FAIL\n";
    }
}
if (is_array($m->parameters)) {
    echo "parameters is an array\n";
}
echo "\nTry to get part 4!\n";
var_dump(imap_bodystruct($imap_stream, 1, "4"));
imap_close($imap_stream);
function isValid($param)
{