Retrieve messages from an IMAP server
$imap = new Imap();
$connection_result = $imap->connect('{imap.gmail.com:993/imap/ssl}INBOX', '[email protected]', 'password');
if ($connection_result !== true) {
echo $connection_result; //Error message!
exit;
}
$messages = $imap->setLimit(10)->getMessages('text', 'asc'); // Return array of messages. Second parameter is for type of sort desc|asc
If you use gmail must allow - https://support.google.com/accounts/answer/6010255?hl=en
php-imap
Installations:
MacOS: brew install kabel/php-ext/[email protected] (php 7.2 in this example)
Ubuntu: sudo apt install php7.2-imap
If this project help you reduce time to develop, you can give me a cup of coffee to continue its development. Thank you! :)