Skip to content

Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)

License

Notifications You must be signed in to change notification settings

jvegaseg/php-imap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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', '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

About

Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%