Skip to content
/ imap Public

PHP IMAP client without php-imap extension dependency

Notifications You must be signed in to change notification settings

gricob/imap

Repository files navigation

Quick start

Install

composer require gricob/imap

Usage

$client = \Gricob\IMAP\Client::create(
    new \Gricob\IMAP\Configuration(
        transport: 'ssl',
        host: 'imap.example.com',
        port: 993,
        timeout: 60,
        verifyPeer: true,
        verifyPeerName: true,
        allowSelfSigned: false,
        useUid: true,
    )
);

$client->logIn('username', 'password');

// List available mailbox
$mailboxes = $client->list();

// Select an specific mailbox
$client->select($mailboxes[0]->name);

// Fetch message by sequence number or uid (depends on useUid configuration)
$message = $client->fetch(1);

// Or search messages by criteria
$messages = $client->search()
    ->since(new DateTime('yesterday'))
    ->get();

Testing

Greenmail standalone IMAP server is configured in the docker compose file for testing. To start it, run the following command:

docker compose up

Once the IMAP server is up and running, run the following command to execute tests:

composer test

About

PHP IMAP client without php-imap extension dependency

Topics

Resources

Stars

Watchers

Forks

Languages