Download the PHP package directorytree/imapengine without Composer

On this page you can find all versions of the php package directorytree/imapengine. 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 imapengine

Working with IMAP doesn't need to be hard.

ImapEngine provides a simple API for managing mailboxes -- without the PHP extension.

Index

Requirements

PHP >= 8.1

Installation

Installation is done through composer:

Usage

ImapEngine provides a simple, fluent API for working with IMAP mailboxes, messages, and attachments.

Connecting

To connect to a mailbox, create a new Mailbox instance with the configuration options:

To connect using an OAuth token, pass the token as the password, and set the authentication method to oauth:

To connect using plain (without encryption) or starttls, set the encryption option to starttls:

There are also many other configuration options available you may find useful:

Debugging

The debug configuration option controls logging behavior for the mailbox.

It accepts the following values:

Boolean:

String: When set to a file path (e.g., '/path/to/log/file.log'), a FileLogger is instantiated to write debug messages to the specified file.

Class Name: If provided with a fully-qualified class name (and the class exists), an instance of that logger will be created and used.

The class must implement DirectoryTree\ImapEngine\Connection\Loggers\LoggerInterface.

Or, if you use Spatie Ray, you may use the built in RayLogger:

Retrieving Folders

Retrieving Messages

ImapEngine provides a fluent, chainable API for building advanced message search queries.

This allows you to combine various search criteria and options to retrieve exactly the messages you need:

[!important] It's paramount to understand that, without any query criteria specified, the get() method fetches all messages in the folder by default, and will be slow for large mailboxes. When working with large mailboxes, consider using since($date), and other criteria filters to limit the number of messages your IMAP server returns, along with pagination or chunking to avoid possible memory issues.

You may also consider restricting the parts of the message you fetch by omitting the use of withHeaders(), withFlags(), and withBody(). This will reduce the amount of data fetched from the server, and speed up your queries.

A typical approach when dealing with large mailboxes is to store all messages (either in a cache or DB) once, and then only fetch new messages since the last time the mailbox was checked.

Filtering By Criteria

The query builder supports many common IMAP search criteria. You may chain methods such as:

For example, to retrieve messages from the last 7 days with a specific subject:

If a method doesn't exist for a specific search criteria, you may use the where() method to add custom criteria:

Fetching Additional Message Data

By default, ImapEngine search queries only fetches UIDs.

To fetch additional message data, you have to enable it explicitly.

Message Flags:

Use withFlags() to retrieve flags, or withoutFlags() to omit them.

Message Body:

Use withBody() to fetch the full body content, or withoutBody() to skip it.

[!important] The withBody() method fetches the full body content of the message, including attachments. Keep this in mind when fetching messages, as it can be slow for large messages.

For example, to fetch messages with both their bodies, headers, and flags:

Message Headers:

Use withHeaders() to include headers in the result, or withoutHeaders() to exclude them.

Message Pagination

You may paginate messages using the paginate() method. This method accepts the number of messages to display per page:

[!important] IMAP does not support native pagination, as you would typically expect, like a SQL database. Instead, ImapEngine retrieves all UID's from the selected folder, takes the slice of the UID's that corresponds to the current page, and fetches the requested email message parts specifically for those UID's.

Message Chunking

If you need to process a large number of messages without loading them all at once, you may use the chunk() method:

You may also use the each() method to iterate over messages in every chunk:

Finding a Specific Message

You may retrieve a single message by its unique identifier using the find() method.

The method accepts an ID and an ImapFetchIdentifier (an enum) that specifies whether the ID is a UID or a message sequence number.

For example, to find a message by UID:

Or by message sequence number:

You may also use the findOrFail() method to throw an exception if the message is not found:

Interacting With Messages

Once you retrieve messages from a folder using methods like $inbox->messages()->get(), you'll receive instances of the DirectoryTree\ImapEngine\Message class.

This class offers a rich set of helper methods for interacting with individual emails, making it easy to inspect, modify, and manipulate messages.

Retrieving Message Information

The Message class provides several methods to access basic properties:

UID and Flags

Headers and Contents

Metadata

Additional Message Details

In addition to the methods shown above, the Message class provides several additional helpers:

Flag Checking

Quickly check whether a message has a specific flag:

Address Handling

To conveniently work with email addresses, the Message class includes methods that return addresses as instances of the DirectoryTree\ImapEngine\Address class:

Content Retrieval

For accessing the message content in different formats:

Attachment Handling

Messages that include attachments can be inspected with:

Flag Operations

The class also provides methods to modify message flags, which help you manage the state of a message:

Marking as Seen/Unseen

Other Flags

All these methods work by invoking the underlying IMAP STORE command (with the appropriate flag and operation).

Message Manipulation

Beyond just flagging, you may move or copy messages between folders, as well as delete them:

Example: Interacting with a Retrieved Message

Creating Draft Messages

ImapEngine allows you to create draft messages and save them to the server for later editing or sending.

To create a new draft message, you may use the append() method on a folder instance:

Draft messages also accept attachments:

`

Idling on Folders (Real Time Monitoring)

ImapEngine supports real-time monitoring of folders via the IMAP IDLE command.

This lets you listen for new messages as they arrive without polling repeatedly.

[!important] The idle() method is fully blocking (as in, it enters an infinite loop), so consider running it in a background process or a worker when used in a web application.

By default, messages received in idle will not be fetched with all of their content (flags, headers, and body with attachments).

If you need to fetch the message content, you may set the query to fetch the desired content using the second argument of the idle() method:

If your IMAP server requires a specific timeout, you may specify one in the third parameter (or using the parameter name):


All versions of imapengine with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
symfony/mime Version >=6.0
nesbot/carbon Version >=2.0
illuminate/collections Version >=9.0
zbateson/mail-mime-parser Version ^3.0
egulias/email-validator Version ^4.0
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 directorytree/imapengine contains the following files

Loading the files please wait ....