nand2 / php-imap
Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)
3.0.7
2019-04-02 09:05 UTC
Requires
- php: >=5.5
- ext-imap: *
README
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
- Symfony - https://github.com/secit-pl/imap-bundle
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', 'some@gmail.com', '*********', __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
- Google Chrome extension PHP Console
- Google Chrome extension JavaScript Errors Notifier