Download the PHP package smartilabs/php-imap without Composer

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

IMAP Library for PHP

Latest Version on Packagist Software License Build Status Total Downloads Hits

Description

PHP-IMAP is a wrapper for common IMAP communication without the need to have the php-imap module installed / enabled. The protocol is completely integrated and therefore supports IMAP IDLE operation and the "new" oAuth authentication process as well. You can enable the php-imap module in order to handle edge cases, improve message decoding quality and is required if you want to use legacy protocols such as pop3.

Wiki: webklex/php-imap/wiki

Laravel wrapper: webklex/laravel-imap

Table of Contents

Installation

1.) Install decoding modules:

1.1.) (optional) Install php-imap module if you are having encoding problems:

You might also want to check phpinfo() if the extensions are enabled.

2.) Now install the PHP-IMAP package by running the following command:

3.) Create your own custom config file like config/imap.php:

Configuration

Supported protocols:

The following encryption methods are supported:

Detailed config/imap.php configuration:

Usage

Basic usage example

This is a basic example, which will echo out all Mails within all imap folders and will move every message into INBOX.read. Please be aware that this should not be tested in real life and is only meant to gives an impression on how things work.

Folder / Mailbox

List all available folders:

Get a specific folder:

oAuth

Please take a look at the wiki article for gmail / google mail setup.

Basic oAuth example:

Idle

Every time a new message is received, the server will notify the client and return the new message.

Search for messages

Search for specific emails:

Available search aliases for a better code reading:

All available query / search methods can be found here: Query::class

Available search criteria:

Further information:

Result limiting

Limiting the request emails:

Counting messages

Count all available messages matching the current search criteria:

Pagination

Paginate a query:

Paginate a message collection:

View example for a paginated list:

You can also paginate a Folder-, Attachment- or FlagCollection instance.

View examples

You can find a few blade examples under /examples.

Fetch a specific message

Get a specific message by uid (Please note that the uid is not unique and can change):

Message flags

Flag or "unflag" a message:

Mark all messages as "read" while fetching:

Don't mark all messages as "read" while fetching:

Attachments

Save message attachments:

Advanced fetching

Fetch messages without body fetching (decrease load):

Fetch messages without body, flag and attachment fetching (decrease load):

Change messages fetch order:

Events

The following events are available:

Create and register your own custom event:

..or set it in your config file under events.message.new.

Masking

PHP-IMAP already comes with two default masks AttachmentMask::class.

The masked instance has to be called manually and is designed to add custom functionality.

You can call the default mask by calling the mask method without any arguments.

There are several methods available to set the default mask:

The last one wont set the mask but generate a masked instance using the provided mask.

You could also set the default masks inside your config/imap.php file under masks.

You can also apply a mask on attachments:

If you want to implement your own mask just extend AttachmentMask::class or Mask::class and implement your desired logic:

Additional examples can be found here:

Specials

Find the folder containing a message:

Support

If you encounter any problems or if you find a bug, please don't hesitate to create a new issue. However please be aware that it might take some time to get an answer. Off topic, rude or abusive issues will be deleted without any notice.

If you need immediate or commercial support, feel free to send me a mail at [email protected].

A little notice

If you write source code in your issue, please consider to format it correctly. This makes it so much nicer to read and people are more likely to comment and help :)

``` php

echo 'your php code...';

```

will turn into:

Features & pull requests

Everyone can contribute to this project. Every pull request will be considered but it can also happen to be declined. To prevent unnecessary work, please consider to create a feature issue first, if you're planning to do bigger changes. Of course you can also create a new feature issue if you're just wishing a feature ;)

Documentation

Client::class

Method Arguments Return Description
setConfig array $config self Set the Client configuration. Take a look at config/imap.php for more inspiration.
getConnection resource $connection resource Get the current imap resource
isConnected bool Determine if connection was established.
checkConnection Determine if connection was established and connect if not.
connect Connect to server.
reconnect Terminate and reconnect to server.
disconnect Disconnect from server.
getFolder string $folder_name, $delimiter = null Folder Get a Folder instance by name or path
getFolders bool $hierarchical, string or null $parent_folder FolderCollection Get folders list. If hierarchical order is set to true, it will make a tree of folders, otherwise it will return flat array.
openFolder string or Folder $folder, integer $attempts Open a given folder.
createFolder string $name boolean Create a new folder.
getQuota array Retrieve the quota level settings, and usage statics per mailbox
getQuotaRoot string $quota_root array Retrieve the quota settings per user
expunge bool Delete all messages marked for deletion
setTimeout string or int $type, int $timeout boolean Set the timeout for certain imap operations: 1: Open, 2: Read, 3: Write, 4: Close
getTimeout string or int $type int Check current mailbox
setDefaultMessageMask string $mask self Set the default message mask class
getDefaultMessageMask string Get the current default message mask class name
setDefaultAttachmentMask string $mask self Set the default attachment mask class
getDefaultAttachmentMask string Get the current default attachment mask class name
getFolderPath string Get the current folder path

Message::class

Method Arguments Return Description
parseBody Message Parse the Message body
delete boolean $expunge boolean Delete the current Message
restore boolean $expunge boolean Restore a deleted Message
copy string $mailbox boolean Copy the current Messages to a mailbox
move string $mailbox, boolean $expunge boolean Move the current Messages to a mailbox
setFlag string or array $flag boolean Set one or many flags
unsetFlag string or array $flag boolean Unset one or many flags
hasTextBody Check if the Message has a text body
hasHTMLBody Check if the Message has a html body
getTextBody string Get the Message text body
getHTMLBody string Get the Message html body
getAttachments AttachmentCollection Get all message attachments
hasAttachments boolean Checks if there are any attachments present
getClient Client Get the current Client instance
getUid string Get the current UID
getFetchOptions string Get the current fetch option
getMsglist integer Get the current message list
getHeaderInfo object Get the current header_info object
getHeader string Get the current raw header
getMessageId string Get the current message ID
getMessageNo integer Get the current message number
getPriority integer Get the current message priority
getSubject string Get the current subject
getReferences mixed Get any potentially present references
getDate Carbon Get the current date object
getFrom array Get the current from information
getTo array Get the current to information
getCc array Get the current cc information
getBcc array Get the current bcc information
getReplyTo array Get the current reply to information
getInReplyTo string Get the current In-Reply-To
getSender array Get the current sender information
getBodies mixed Get the current bodies
getRawBody mixed Get the current raw message body
getFlags FlagCollection Get the current message flags
is boolean Does this message match another one?
getStructure object The raw message structure
getFolder Folder The current folder
mask string $mask = null Mask Get a masked instance
setMask string $mask Message Set the mask class
getMask string Get the current mask class name

Folder::class

Method Arguments Return Description
hasChildren bool Determine if folder has children.
setChildren array $children self Set children.
delete Delete the current Mailbox
subscribe Subscribe to the current Mailbox
unsubscribe Unsubscribe from the current Mailbox
idle callable $callback(Message $new_message) Idle the current folder
move string $mailbox Move or Rename the current Mailbox
rename string $mailbox Move or Rename the current Mailbox
getStatus array Returns status information on the current mailbox
examine array Returns status information on the current mailbox
appendMessage string $message, string $options, string $internal_date bool Append a string message to the current mailbox
getClient Client Get the current Client instance
query string $charset = 'UTF-8' WhereQuery Get the current Client instance
messages string $charset = 'UTF-8' WhereQuery Alias for Folder::query()
search string $charset = 'UTF-8' WhereQuery Alias for Folder::query()

Query::class

Method Arguments Return Description
where mixed $criteria, $value = null WhereQuery Add new criteria to the current query
orWhere Closure $closure WhereQuery If supported you can perform extended search requests
andWhere Closure $closure WhereQuery If supported you can perform extended search requests
all WhereQuery Select all available messages
answered WhereQuery Select answered messages
deleted WhereQuery Select deleted messages
new WhereQuery Select new messages
not WhereQuery Not select messages
old WhereQuery Select old messages
recent WhereQuery Select recent messages
seen WhereQuery Select seen messages
unanswered WhereQuery Select unanswered messages
undeleted WhereQuery Select undeleted messages
unflagged WhereQuery Select unflagged messages
unseen WhereQuery Select unseen messages
noXSpam WhereQuery Select as no xspam flagged messages
isXSpam WhereQuery Select as xspam flagged messages
language string $value WhereQuery Select messages matching a given language
unkeyword string $value WhereQuery Select messages matching a given unkeyword
messageId string $value WhereQuery Select messages matching a given message id
to string $value WhereQuery Select messages matching a given receiver (To:)
text string $value WhereQuery Select messages matching a given text body
subject string $value WhereQuery Select messages matching a given subject
since string $value WhereQuery Select messages since a given date
on string $value WhereQuery Select messages on a given date
keyword string $value WhereQuery Select messages matching a given keyword
from string $value WhereQuery Select messages matching a given sender (From:)
flagged string $value WhereQuery Select messages matching a given flag
cc string $value WhereQuery Select messages matching a given receiver (CC:)
body string $value WhereQuery Select messages matching a given HTML body
before string $value WhereQuery Select messages before a given date
bcc string $value WhereQuery Select messages matching a given receiver (BCC:)
count integer Count all available messages matching the current search criteria
get MessageCollection Fetch messages with the current query
limit integer $limit, integer $page = 1 WhereQuery Limit the amount of messages being fetched
setFetchOptions boolean $fetch_options WhereQuery Set the fetch options
setFetchBody boolean $fetch_body WhereQuery Set the fetch body option
setFetchFlags boolean $fetch_flags WhereQuery Set the fetch flags option
setFetchOrder string $fetch_order WhereQuery Change the fetch ordering (asc is "oldest first", desc is "newest first")
setFetchOrderAsc WhereQuery Change the fetch ordering to ascending
setFetchOrderDesc WhereQuery Change the fetch ordering to descending
leaveUnread WhereQuery Don't mark all messages as "read" while fetching:
markAsRead WhereQuery Mark all messages as "read" while fetching
paginate int $perPage = 5, $page = null, $pageName = 'imap_page' LengthAwarePaginator Paginate the current query.

Attachment::class

Method Arguments Return Description
getContent string or null Get attachment content
getMimeType string or null Get attachment mime type
getExtension string or null Get a guessed attachment extension
getId string or null Get attachment id
getName string or null Get attachment name
getContent string or null Get attachment content
setSize int or null Get attachment size
getType string or null Get attachment type
getDisposition string or null Get attachment disposition
getContentType string or null Get attachment content type
save string $path, string $filename boolean Save the attachment content to your filesystem
mask string $mask = null Mask Get a masked instance
setMask string $mask Attachment Set the mask class
getMask string Get the current mask class name

Mask::class

Method Arguments Return Description
getParent Masked parent Get the masked parent object
getAttributes array Get all cloned attributes
__get mixed Access any cloned parent attribute
__set mixed Set any cloned parent attribute
__inherit mixed All public methods of the given parent are callable

MessageMask::class

Method Arguments Return Description
getHtmlBody string or null Get HTML body
getCustomHTMLBody callable or bool $callback string or null Get a custom HTML body
getHTMLBodyWithEmbeddedBase64Images string or null Get HTML body with embedded base64 images
getHTMLBodyWithEmbeddedUrlImages string $route_name, array $params = [] string or null Get HTML body with embedded routed images

AttachmentMask::class

Method Arguments Return Description
getContentBase64Encoded string or null Get attachment content
getImageSrc string or null Get attachment mime type

MessageCollection::class

Extends Illuminate\Support\Collection::class

Method Arguments Return Description
paginate int $perPage = 15, $page = null, $pageName = 'page' LengthAwarePaginator Paginate the current collection.

FlagCollection::class

Extends Illuminate\Support\Collection::class

Method Arguments Return Description
paginate int $perPage = 15, $page = null, $pageName = 'page' LengthAwarePaginator Paginate the current collection.

AttachmentCollection::class

Extends Illuminate\Support\Collection::class

Method Arguments Return Description
paginate int $perPage = 15, $page = null, $pageName = 'page' LengthAwarePaginator Paginate the current collection.

FolderCollection::class

Extends Illuminate\Support\Collection::class

Method Arguments Return Description
paginate int $perPage = 15, $page = null, $pageName = 'page' LengthAwarePaginator Paginate the current collection.

Known issues

Error Solution
Kerberos error: No credentials cache file found (try running kinit) (...) Uncomment "DISABLE_AUTHENTICATOR" inside and use the legacy-imap protocol

Change log

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of php-imap with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
ext-openssl Version *
ext-json Version *
ext-mbstring Version *
ext-iconv Version *
ext-fileinfo Version *
nesbot/carbon Version >=1.0
symfony/http-foundation Version >=2.8.0
illuminate/pagination Version >=5.0.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 smartilabs/php-imap contains the following files

Loading the files please wait ....