<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lecodeurdudimanche / laravel-email-listener example snippets
$schedule->call(new EmailListener)->everyfiveMinutes(); // or any other [frequency option](https://laravel.com/docs/5.7/scheduling#schedule-frequency-options)
$action = (new Action())
->filter((new EmailFilter())
->from("[email protected]")
)
->callback($callback);
// callback can be a closure, a array with class and method or a string with format 'class@method'
// Tou can also use the constructor
$action = new Action(
(new EmailFilter())->from("[email protected]"),
$callback);
$emailListener = (new EmailListener())
->addAction('imap_client', $action);
// Where 'imap_client' is the name of your IMAP or POP account in config/imap.php file
$emailListener->run();
$emailListener->save();
(new EmailListener())
->load()
->addAction('imap_client', $action)
->save();
// You must either set config("email-listener.config-file") to the path of your JSON file
// or pass the path as the second argument of Filter::load
$filter = Filter::load('fancyFilterName', 'path/to/file.json');
$filter->save('path/to/file.json');
// You can also save the filter with another name like so :
$filter->saveAs('another name', 'path/to/file.json');