Login

IMAP Parser PHP


Read email inbox. IMAP mailbox parse using PHP & return Array or JSON.

Sample:

<?php

// include Imap_parser class
include_once('lib/Imap_parser.php');

// create Imap_parser Object
$email = new Imap_parser();

// data
$data = array(
    // email account
    'email' => array(
        'hostname' => '{mail.ibacor.com:143/notls}INBOX',
        'username' => 'me@ibacor.com',
        'password' => 'omt3l0l3t0m'    
    ),
    // inbox pagination
    'pagination' => array(
        'sort' => 'ASC', // or DESC
        'limit' => 3,
        'offset' => 9
    )
);

// get inbox. Array
$result = $email->inbox($data);

// Array
print_r($result);

// JSON
// echo json_encode($result);

Result:

Array
(
    [status] => success
    [email] => me@ibacor.com
    [count] => 113
    [inbox] => Array
        (
            [0] => Array
                (
                    [id] => 10
                    [subject] => Re: [bachors/jQuery-Youtube-Channels-Playlist]
                    [from] => anu
                    [email] => anu@hotmail.it
                    [date] => Thu, 24 Nov 2016 11:12:02 +0000
                    [message] => Hi, I'm anu on github.
                    [image] => data:image/jpeg;base64,...
                )

            [1] => Array
                (
                    ...
                )

            [2] => Array
                (
                    ...
                )

        )

    [pagination] => Array
        (
            [sort] => ASC
            [limit] => 3
            [offset] => Array
                (
                    [back] => 6
                    [next] => 12
                )

        )

)

Demo Fork me on GitHub