#!/bin/php
<?php

include '../core.php';
include '../system.inc.php';

$login = "customer@svam-ci.com";
$password = "test@123";

$host = '{mail.alpha-assist.com:7143/imap/novalidate-cert}INBOX';
$mail_con = imap_open($host, $login, $password);
$mailboxes = imap_list($mail_con, $host, '*');

function mailserver_stat($connection)       
{
    $check = imap_mailboxmsginfo($connection);
    return ((array)$check);
}

function mailserver_list($connection,$message="")
{ 
    $result = "";
    if ($message)
    {
        $range=$message; 
    } else {
        $MC = imap_check($connection);
        $range = "1:".$MC->Nmsgs;
    }
    $response = imap_fetch_overview($connection,$range);
    foreach ($response as $msg) {
        $result[$msg->msgno] = (array) $msg;
    }
    return $result;
}


function mailserver_retr($connection,$message)
{

    return(imap_fetchheader($connection,$message,FT_PREFETCHTEXT));
}

$result = mailserver_list($mail_con,"");
print_r($result[1]['seen']) ;
