1. Go to this page and download the library: Download smart/emailreader library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Smart\EmailReader\Dispatcher\Dispatcher;
class DispatcherApp extends Dispatcher
{
public function __construct()
{
$this->addDispatcher(new SupportEmailDispatcher());
//you can add as many dispatchers as you want....
}
}
use Smart\EmailReader\Dispatcher\Dispatcher;
use Smart\EmailReader\EmailEntity;
class SupportEmailDispatcher extends Dispatcher
{
public function __construct()
{
$this->addHandler('#\[support\-(?<id>[0-9]+)\]#i', [$this, 'handleNewReply']);
}
public function handleNewReply($matches, EmailEntity $email)
{
$ticketId = isset($matches['id']) ? (int)$matches['id'] : null;
$newReply = $email->getLastReply();
//your logic here...
}
}
$emailReader = new Fetch(
new EmailServerConfig() //check the configuration section
);
$emailLoggerLogger = new EmailReaderLogger(
'/log/path_to_your_log_file'
);
//add this in sinergi gearman :
new EmailReaderDispatchJob(
$emailReader,
new DispatcherApp(), //your own dispatcher
$emailLoggerLogger
);
$consoleApp = new ConsoleApplication();
$gearmanDispatcher = '...'; //get your gearman dispatcher
$consoleApp->add(
new EmailReaderSendCommand(
$gearmanDispatcher,
$emailReader
)
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.