Download the PHP package ddeboer/imap without Composer
On this page you can find all versions of the php package ddeboer/imap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Rated 5.00 based on 1 reviews
Informations about the package imap
PHP IMAP library
A PHP IMAP library to read and process e-mails over IMAP protocol, built with robust Object-Oriented architecture.
This library requires PHP >= 8.3 with IMAP, iconv and Multibyte String extensions installed.
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:
- https://stackoverflow.com/questions/36356715/imap-search-unknown-search-criterion-or
- 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 (only first part):
Get complete body (all parts):
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.
Contributing: run the build locally
Docker is needed to run the build on your computer.
First command you need to run is make start-imap-server
, which starts an IMAP server locally.
Then the local build can be triggered with a bare make
.
When you finish the development, stop the local IMAP server with make stop-imap-server
.
All versions of imap with dependencies
ext-dom Version *
ext-iconv Version *
ext-imap Version *
ext-libxml Version *
ext-mbstring Version *