Sample code for 30+ languages & platforms
PHP

IMAP Session Logging

Demonstrates how to use session logging with IMAP.

Chilkat PHP Downloads

PHP
<?php

use Chilkat2\Imap;

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

$imap = new Imap();

// Set the KeepSessionLog property to enable IMAP session logging
$imap->KeepSessionLog = true;

// Connect to an IMAP server.
// Use TLS
$imap->Ssl = true;
$imap->Port = 993;
try {
    $imap->Connect('imap.example.com');

    // Login
    $imap->Login('mylogin', 'mypassword');

    // Select an IMAP mailbox
    $imap->SelectMailbox('Inbox');
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

// We're not really doing anything in this example
// other than to show how to examine the IMAP component's session log...

// Disconnect from the IMAP server.
$imap->Disconnect();

// Display the session log...
echo $imap->SessionLog, "\n";