drakonli / php-imap
PHP OOP library for accessing mailbox by POP3/IMAP/NNTP using IMAP extension
Requires
- php: >=5.6.0 <7.0.0
- ext-imap: *
- ext-spl_types: *
- drakonli/php-utils: dev-master
- symfony/config: ^3.0.0
- symfony/dependency-injection: ^3.0.0
- symfony/yaml: ^3.0.0
Requires (Dev)
- php-mock/php-mock-phpunit: dev-master
- phpspec/prophecy: ~1.0
- phpunit/phpunit: 5.5.*
This package is not auto-updated.
Last update: 2025-01-18 21:52:44 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
- Create a connection
- Inject services into your Client (like RepositoryInterface). All services you can find here and their dependency config here.
- 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.
- 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.
- Example here: PreDefinedConnectionFactoryEmailDisplayer
- Services: services.yml
- 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.
- Example here: ConnectionInjectedEmailDisplayer
- Services: services.yml
-
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:)
- Example non-strict here: NonStrictFactoryMethodEmailDisplayer
- Services: services.yml
- Example with builders here: BuildersEmailDisplayer
- Services: services.yml
And check out the parameters.yml file - it will help you understand services configuration better.
Have fun:)