Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.91 KB

README.md

File metadata and controls

52 lines (36 loc) · 1.91 KB

PHP IMAP

Author GitHub release Software License Packagist

Features

  • 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

Requirements

  • IMAP extension must be present; so make sure this line is active in your php.ini: extension=php_imap.dll

Installation by Composer

$ composer require php-imap/php-imap

Integration with frameworks

Usage example

// 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());

Recommended