drakonli/php-imap

PHP OOP library for accessing mailbox by POP3/IMAP/NNTP using IMAP extension

dev-master 2016-12-11 17:25 UTC

This package is not auto-updated.

Last update: 2024-04-27 17:28:08 UTC


README

What is PHP IMAP?

Basically, it's an Object Oriented wrapper for IMAP library. It's meant to be used in a Object Oriented project and even supplies it's own dependency container (Dependency Injection Symfony Component)

This project uses SPL TYPES, because the forked project was for PHP prio to php7 and so there are no return types and scalar hints.

Requirements

HOW TO USE

Following examples are from my php-imap examples repository

  1. Create a connection
  2. Inject services into your Client (like RepositoryInterface). All services you can find here and their dependency config here.
  3. Pass instantiated connection to services to do any kind of IMAP action.

Now, the most interesting part is how you create a connection. There are multiple ways to do so. These ways differ depending on how you would like to instantiate the connection method and amount of knowledge you have about flags, options and params and their values.

  1. If you don't know anything about them, you might just want to use factories and builders to create your own connection and connection config. And for that I recommend creating a Factory that implements PreDefinedConnectionFactoryInterface for each service you want to create IMAP connection to (because the connection settings are basically the same for one service - only login/password/mailbox are different). For example - Gmail.
  1. If you do know about them, use dependency injection factory method to create a connection and inject it straight into the client. For that you'll have to use ConnectionFactoryInterface::createConnectionNonStrict. Mind that even though the interface is non-strict, internally SplTypes and the Flags-, Params-, Options- Collection is instantiated.
  1. You can also use ConnectionFactoryInterface to create connection straight in the Client using strict (builders, factories, etc...) and non-strict (constants) syntax. I advice not to do it!, though:)

And check out the parameters.yml file - it will help you understand services configuration better.

Have fun:)