Download the PHP package smart/emailreader without Composer
On this page you can find all versions of the php package smart/emailreader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smart/emailreader
More information about smart/emailreader
Files in smart/emailreader
Package emailreader
Short Description Email reader and dispatcher powered by Gearman
License MIT
Homepage https://github.com/smart-io/email-reader
Informations about the package emailreader
EmailReader
This library will read emails of a specific mailbox, will parse them and finally, dispatch them to handlers. How to install
This library is used to read email (you can inject your own by implementing the DriverInterface) : https://github.com/tedious/Fetch
Inside our Fetch driver, we used this library to parse the last email reply : https://github.com/willdurand/EmailReplyParser
How is it working ?
- This library contains a command which is gonna check all new emails in your mailbox and give them to gearman. 1 new email = 1 new task on gearman.
- The gearman job will read the email, parse it and then, dispatch it to your application.
- Once gearman is finished with this email, the email is move to another folder to mark it as processed.
configuration
Config | Default | Description |
---|---|---|
domain | Address of your mail serveur (eg. imap.gmail.com) | |
port | 143 | SSL port is usually 993, normal is 143 |
service | Imap | Imap or Pop |
username | You email username, most of the time it's your email | |
password | Your email password | |
main mailbox | The mailbox where this library will read new emails | |
processed mailbox | Where to move the emails once processed |
example :
Dispatch
This library come with a dispatcher base class which allows you to handle different kind of email. The handlers on the dispatcher work like a router on the email subject.
example
Imagine we have support ticket system on our app. We want our customer to be able to reply directly to the email to add their reply in our ticket system.
About dispatchers :
- The dispatcher don't stop at the first match, different regexs can overlap themself
- If you return false on a dispatcher, the dispatcher will stop there and complete the task
- Currently, you can only dispatch the email based on the subject
Installation
Dependencies
This should be place in your app container
Gearman job
We use Sinergi gearman : https://github.com/sinergi/gearman
Register Command
We use symfony console : https://github.com/symfony/Console
Finally, you just need to add a cron on that command every few minutes to read incoming email and dispatch them into your application.
All versions of emailreader with dependencies
symfony/console Version ~2
sinergi/token Version <1
psr/log Version ~1
tedivm/fetch Version 0.6.*
willdurand/email-reply-parser Version ~2.3