- Connect to mailbox by POP3/IMAP/NNTP, using PHP IMAP extension
- Get emails with attachments and inline images
- Get emails filtered or sorted by custom criteria
- Mark emails as seen/unseen
- Delete emails
- Manage mailbox folders
- IMAP extension must be present; so make sure this line is active in your php.ini:
extension=php_imap.dll
$ composer require php-imap/php-imap
// 4. argument is the directory into which attachments are to be saved:
$mailbox = new PhpImap\Mailbox('{imap.gmail.com:993/imap/ssl}INBOX', '[email protected]', '*********', __DIR__);
// Read all messaged into an array:
$mailsIds = $mailbox->searchMailbox('ALL');
if(!$mailsIds) {
die('Mailbox is empty');
}
// Get the first message and save its attachment(s) to disk:
$mail = $mailbox->getMail($mailsIds[0]);
print_r($mail);
echo "\n\nAttachments:\n";
print_r($mail->getAttachments());
- Google Chrome extension PHP Console
- Google Chrome extension JavaScript Errors Notifier