gricob / imap
IMAP client for PHP without php-imap extension dependency
Installs: 2 470
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 3
Open Issues: 0
Requires
- php: ^8.2
- ext-ctype: *
- ext-iconv: *
- doctrine/lexer: ^3.0
- psr/log: ^1.0|^2.0|^3.0
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^11.0
README
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->mailboxes(); // Select an specific mailbox $client->select($mailboxes[0]); // 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')) ->not()->header('In-Reply-To')) ->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