{"id":23686378,"url":"https://github.com/lecodeurdudimanche/laravel-email-listener","last_synced_at":"2026-01-09T01:30:15.194Z","repository":{"id":57013436,"uuid":"222147739","full_name":"LeCodeurDuDimanche/laravel-email-listener","owner":"LeCodeurDuDimanche","description":" Simple library to do actions when receiving emails, desgined to work with Laravel","archived":false,"fork":false,"pushed_at":"2019-11-19T21:51:34.000Z","size":1437,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-29T21:32:15.553Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/lecodeurdudimanche/laravel-email-listener","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LeCodeurDuDimanche.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-16T19:17:21.000Z","updated_at":"2019-11-19T21:51:35.000Z","dependencies_parsed_at":"2022-08-21T13:40:55.068Z","dependency_job_id":null,"html_url":"https://github.com/LeCodeurDuDimanche/laravel-email-listener","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeCodeurDuDimanche%2Flaravel-email-listener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeCodeurDuDimanche%2Flaravel-email-listener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeCodeurDuDimanche%2Flaravel-email-listener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeCodeurDuDimanche%2Flaravel-email-listener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeCodeurDuDimanche","download_url":"https://codeload.github.com/LeCodeurDuDimanche/laravel-email-listener/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239742418,"owners_count":19689309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-29T21:30:44.509Z","updated_at":"2026-01-09T01:30:15.127Z","avatar_url":"https://github.com/LeCodeurDuDimanche.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Email Listener \n[![Build status][ci_badge]][github_actions] \n[![GitHub license][license_badge]][license_url]\n[![Package version][version_badge]][packagist_url] \n[![Downloads][downloads_badge]][packagist_url]\n\nA simple library to do actions when receiving emails, desgined to work with Laravel\n\n## Installation\nVia composer :\n```bash\ncomposer require lecodeurdudimanche/laravel-email-listener\n```\n\nYou will need to install and enable some `php` extensions (`php-imap`, `php-mbstring` and `php-mcrypt`).\nWith Ubuntu :\n```bash\nsudo apt install php*-imap php*-mbstring php*-mcrypt\n```\n\n## Configuration\n\nYou need to set the configuration of your IMAP or POP accounts.\nFirst run the following command to publish the configration in your `config` folder :\n```bash\nphp artisan vendor:publish --provider=\"Webklex\\IMAP\\Providers\\LaravelServiceProvider\"\n```\n\nNext, modify the `accounts` configuration to add your own accounts.\n\nThis library uses [laravel-imap](https://github.com/Webklex/laravel-imap) for IMAP and POP communication, so if you need more help about IMAP and POP configuration take a look at [their documentation](https://github.com/Webklex/laravel-imap#configuration).\n\n## Basic usage\n\nIn the [schedule()](https://laravel.com/docs/5.7/scheduling#defining-schedules) method of your `App\\Console\\Kernel` class, add this line :  \n```php\n$schedule-\u003ecall(new EmailListener)-\u003eeveryfiveMinutes(); // or any other [frequency option](https://laravel.com/docs/5.7/scheduling#schedule-frequency-options)\n```\n\nThis will cause the `EmailListener` to load actions and filters from the configuration file (whose path must be provided in `email-listener.config-file` configuration value) and then run.\n\nIn order to create the configuration programtically, or to use the library without loading anything, you'll need to register `Action`s.\nFirst, you'll need to create an `Action` object, that contains a callback to be executed and a filter determining which email will trigger that action :\n```php\n$action = (new Action())\n    -\u003efilter((new EmailFilter())\n        -\u003efrom(\"an.adress@example.com\")\n        )\n    -\u003ecallback($callback);\n// callback can be a closure, a array with class and method or a string with format 'class@method'\n// Tou can also use the constructor\n$action = new Action(\n    (new EmailFilter())-\u003efrom(\"an.adress@example.com\"),\n    $callback);\n```\nYou can now bind that action to an `EmailListener` :\n```php\n$emailListener = (new EmailListener())\n    -\u003eaddAction('imap_client', $action);\n\n// Where 'imap_client' is the name of your IMAP or POP account in config/imap.php file\n```\n\nAnd then run it or save it :\n```php\n$emailListener-\u003erun();\n$emailListener-\u003esave();\n```\n\nFor instance, this is the code to add an action to an existing listener and then save it :\n```php\n(new EmailListener())\n    -\u003eload()\n    -\u003eaddAction('imap_client', $action)\n    -\u003esave();\n```\n\n\nYou can load filters individually from JSON with the `Filter::load()` function and save them with the `Filter::save()` fonction like so :\n```php\n// You must either set config(\"email-listener.config-file\") to the path of your JSON file\n// or pass the path as the second argument of Filter::load\n$filter = Filter::load('fancyFilterName', 'path/to/file.json');\n$filter-\u003esave('path/to/file.json');\n// You can also save the filter with another name like so :\n$filter-\u003esaveAs('another name', 'path/to/file.json');\n```\n\nDescription of the expected format :\n```\n  {\n      \"actions\" : [\n        {\n            \"client\" : \u003cclient_name\u003e,\n            \"filter\" : \u003cfilter_name\u003e,\n            \"callback\" : \"class@method\"\n        },\n        ...\n      ],\n      \"filters\" : [\n          \u003cfilterName\u003e : {\n            \"type\": \"email\" | \"attachment\",\n            \"filters\": [\n              {\n                  \"method\" : \u003cfilter\u003e,\n                  \"args\" : \u003cargument\u003e | \u003carray of arguments\u003e\n              },\n              ...\n            ]\n            (\"attachments\" : \u003cfilterDescription\u003e)(only if type == \"email\", optional)\n          },\n          ...\n      ]\n}\n```\nAn example can be found in the [tests directory](tests/data/filters.json).\n\n## Full API\n_Coming soon_\n\n[ci_badge]: https://github.com/lecodeurdudimanche/laravel-email-listener/workflows/CI/badge.svg\n[github_actions]:https://github.com/LeCodeurDuDimanche/laravel-email-listener/actions?query=workflow%3ACI\n[version_badge]: https://img.shields.io/packagist/v/lecodeurdudimanche/laravel-email-listener.svg\n[downloads_badge]: https://img.shields.io/packagist/dt/lecodeurdudimanche/laravel-email-listener.svg?color=blue\n[packagist_url]: https://packagist.org/packages/lecodeurdudimanche/laravel-email-listener\n[license_badge]: https://img.shields.io/github/license/LeCodeurDuDimanche/laravel-email-listener\n[license_url]: https://github.com/LeCodeurDuDimanche/laravel-email-listener/blob/master/License.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flecodeurdudimanche%2Flaravel-email-listener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flecodeurdudimanche%2Flaravel-email-listener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flecodeurdudimanche%2Flaravel-email-listener/lists"}