1. Go to this page and download the library: Download khaled-00/imap library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
khaled-00 / imap example snippets
use Ddeboer\Imap\Server;
$server = new Server('imap.gmail.com');
// $connection is instance of \Ddeboer\Imap\Connection
$connection = $server->authenticate('my_username', 'my_password');
$server = new Server(
$hostname, // flags, // defaults to '/imap/ssl/validate-cert'
$parameters
);
$mailboxes = $connection->getMailboxes();
foreach ($mailboxes as $mailbox) {
// $mailbox is instance of \Ddeboer\Imap\Mailbox
printf('Mailbox %s has %s messages', $mailbox->getName(), $mailbox->count());
}
$mailbox = $connection->getMailbox('INBOX');
$mailbox->delete();
$messages = $mailbox->getMessages();
foreach ($messages as $message) {
// $message is instance of \Ddeboer\Imap\Message
}
use Ddeboer\Imap\SearchExpression;
use Ddeboer\Imap\Search\Email\To;
use Ddeboer\Imap\Search\Text\Body;
$search = new SearchExpression();
$search->addCondition(new To('[email protected]'))
->addCondition(new Body('contents'))
;
$messages = $mailbox->getMessages($search);