Download the PHP package php-experts/imap without Composer

On this page you can find all versions of the php package php-experts/imap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package imap

IMAP library

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Total Downloads

A PHP 7.1+ library to read and process e-mails over IMAP.

This library requires IMAP, iconv and Multibyte String extensions installed.

Table of Contents

  1. Feature Requests
  2. Installation
  3. Usage
    1. Connect and Authenticate
    2. Mailboxes
    3. Messages
      1. Searching for Messages
      2. Unknown search criterion: OR
      3. Message Properties and Operations
    4. Message Attachments
    5. Embedded Messages
    6. Timeouts
  4. Mock the library
  5. Running the Tests
    1. Running Tests using Docker

Feature Requests

Feature Requests

Installation

The recommended way to install the IMAP library is through Composer:

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Usage

Connect and Authenticate

You can specify port, flags and parameters to the server:

Mailboxes

Retrieve mailboxes (also known as mail folders) from the mail server and iterate over them:

Or retrieve a specific mailbox:

Delete a mailbox:

You can bulk set, or clear, any flag of mailbox messages (by UIDs):

WARNING You must retrieve new Message instances in case of bulk modify flags to refresh the single Messages flags.

Messages

Retrieve messages (e-mails) from a mailbox and iterate over them:

To insert a new message (that just has been sent) into the Sent mailbox and flag it as seen:

Note that the message should be a string at MIME format (as described in the RFC2045).

Searching for Messages

WARNING We are currently unable to have both spaces and double-quotes escaped together. Only spaces are currently escaped correctly. You can use Ddeboer\Imap\Search\RawExpression to write the complete search condition by yourself.

Messages can also be retrieved sorted as per imap_sort function:

Unknown search criterion: OR

Note that PHP imap library relies on the c-client library available at https://www.washington.edu/imap/ which doesn't fully support some IMAP4 search criteria like OR. If you want those unsupported criteria, you need to manually patch the latest version (imap-2007f of 23-Jul-2011 at the time of this commit) and recompile PHP onto your patched c-client library.

By the way most of the common search criteria are available and functioning, browse them in ./src/Search.

References:

  1. https://stackoverflow.com/questions/36356715/imap-search-unknown-search-criterion-or
  2. imap-2007f.tar.gz: ./src/c-client/mail.c and ./docs/internal.txt

Message Properties and Operations

Get message number and unique message id in the form <...>:

Get other message properties:

Get message headers as a \Ddeboer\Imap\Message\Headers object:

Get message body as HTML or plain text:

Reading the message body keeps the message as unseen. If you want to mark the message as seen:

Or you can set, or clear, any flag:

Move a message to another mailbox:

Deleting messages:

Message Attachments

Get message attachments (both inline and attached) and iterate over them:

Download a message attachment to a local file:

Embedded Messages

Check if attachment is embedded message and get it:

An EmbeddedMessage has the same API as a normal Message, apart from flags and operations like copy, move or delete.

Timeouts

The IMAP extension provides the imap_timeout function to adjust the timeout seconds for various operations.

However the extension's implementation doesn't link the functionality to a specific context or connection, instead they are global. So in order to not affect functionalities outside this library, we had to choose whether wrap every imap_* call around an optional user-provided timeout or leave this task to the user.

Because of the heterogeneous world of IMAP servers and the high complexity burden cost for such a little gain of the former, we chose the latter.

Mock the library

Mockability is granted by interfaces present for each API. Dig into MockabilityTest for an example of a mocked workflow.

Running the Tests

This library is functionally tested on Travis CI against a local Dovecot server.

If you have your own IMAP (test) account, you can run the tests locally by providing your IMAP credentials:

You can also copy phpunit.xml.dist file to a custom phpunit.xml and put these environment variables in it:

WARNING Tests create new mailboxes without removing them.

Running Tests using Docker

If you have Docker installed you can run the tests locally with the following command:


All versions of imap with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
ext-iconv Version *
ext-imap Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package php-experts/imap contains the following files

Loading the files please wait ....