Download the PHP package craigh/imap-mail-manager without Composer

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

ImapMailManager

ImapMailManager provides convenient OOP classes for performing common tasks when for managing incoming email via imap in php.

Note: This package is now under a beta realease. A fully stable realease is expected in the coming weeks.

Features

Getting Started

ImapMailManager provides two main service classes for performing tasks on the Mailbox (searching the mailbox for messages, folders etc) and on the Message itself (downloading attachments). Convenient factories have been provided to help with the creation of required objects.

Config

The simplest way to connect to your mailbox is by providing the settings via a config file.

Aliases

Aliases provide a convenient way to reference mailbox folders, for example if you use different config files to connect to multiple mailboxes you can provide folder aliases in the config itself. This means you can avoid hardcoding folder names, and using if statements to detect which mailbox you are connected to to get the correct folder name. To create an alias, you simply need to add an aliases array to your config file, these aliases can then be passed to methods that request a folder name, e.g. moveToFolder('spam'):

It's a good idea to add the trash alias, as this is the alias that is automatically used by the moveToTrash() and emptyTrash() methods. Otherwise you will need to pass the folder name in as a parameter: e.g. moveToTrash('INBOX.Trash')

Generating the config file

ImapMailManager provides a config generator called createImapConfig.php which can be run from composers vendor/bin folder, which will create 'imap_config/config.php' in the folder the script is run from.

Alternatively, you can simply copy and paste the code from config.php to your own config file.

By default ImapMailManager looks for your config file in imap_config/config.php, you can change this by passing the config location directly in to the relevant class constructors or factory methods. (see docs)

Listing Emails

This following example uses the provided factories to build a collection of messages from your inbox. See Creating Imap using constructors and no config below to see how you may use constructors to acheive the same results.

Now you can simply loop through the messages to display a list of message subjects:

Displaying a message

You should look at the docs for the ImapMessage class to see what methods are availble for retrieving message information. You can also look at examples\showMessage.php which provides a more complete example of displaying a message.

Handling Attachments

ImapMailManager takes all the pain out of downloading attachments by extracting the attachment information, decoding and saving the attachment to the relevant folder.

Downloading all attachments

To download all attachments for a message you simply need the following:

Downloading A Single Attachment

You will often want to download a single attachment, in order to do this ImapMailManager provides a few convenience methods: downloadAttachmentByFilename(), downloadAttachmentByPart() and downloadAttachment(). You can use the getAttachments() method on the returned message to retrieve a collection of Attachment objects which provide getFilename() and getPart() methods:

Downloading attachment by filename

Downloading Embedded images

Some E-mails have images directly embedded in them, by default ImapMailManager will not download these images, so they will not be displayed. If you want to download and display embedded images you simply need to call the downloadEmbeddedImages() method, when displaying the message:

In order to avoid overwriting images embedded images are saved to your/path/folderName/messageNumber.

Note: Embedded images are only downloaded if they do not exist in the download location, they will not be downloaded each time the message is opened.

Creating Imap using constructors and no config

While the factory methods provide a convenient way to create an the Imap class that is passed in to a service or factory, it hides a lot of what is going on. In order to better understand how ImapMailManager works, the following shows how you would directly construct the MailboxService object:

Note: Creating a Message object directly is quite involved, so the Factories should still be used to create Message objects and collections.

Running the Examples

The examples require you to provide your own config file in examples/imap_config/config.php, you can do this by using the generator found in vendor\bin or simply creating one manually, you can find the basic config file in config.php in the root of this project.

You then need to change the settings in your config.php file to match your email account and you should then be able to run the examples.

Documentation

There's a lot more that can be done with ImapMailManager than just these examples. You can find the full list of methods and descriptions in the docs folder, provided as HTML. I hope to have these online soon.

Notes

A Note About Collections

ImapMailMainager returns collections as Collection objects. You can treat these exactly as you would a normal php array, so you can still use count and foreach on them as well as access them via their array index MessageCollection[0]

A Note on JSON Encoding

All value objects and collections are designed to be easily json encodable (and provide a toJson() method), however, you may find that some parts of an object are not included when json encoded, these are generally the raw responses from php's imap functions which could cause json_encode() to fail if they are not UTF-8 encoded.

A Note on echoing

All value objects and collections have a __toString() method that will automatically display their json representations if echoed or printed to the screen, so you don't need to var_dump(). You should be aware that json is not the actual returned value when creating an object, but it's string represntation, so all methods can be used on the object as normal.

A Note About Cloning

Classes that contain properties that are objects are deep cloned, so those object properties are thmeselves clones.


All versions of imap-mail-manager with dependencies

PHP Build Version
Package Version
Requires nesbot/carbon Version ^1.21
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 craigh/imap-mail-manager contains the following files

Loading the files please wait ....