Download the PHP package smartilabs/laravel-imap without Composer
On this page you can find all versions of the php package smartilabs/laravel-imap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smartilabs/laravel-imap
More information about smartilabs/laravel-imap
Files in smartilabs/laravel-imap
Package laravel-imap
Short Description Laravel IMAP client
License MIT
Homepage https://github.com/webklex/laravel-imap
Informations about the package laravel-imap
IMAP Library for Laravel
Description
Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app. This enables your app to not only respond to new emails but also allows it to read and parse existing mails and much more.
If you want to use this library outside of Laravel, please head over to webklex/php-imap for a standalone version.
Table of Contents
- Documentations
- Installation
- Configuration
- Usage
- Basic usage example
- Facade
- View examples
- Idle
- oAuth
- Events
- Commands
- Event driven
- Custom command
- Service setup
- Support
- Known issues
- Security
- Credits
- Supporters
- License
Documentations
- Legacy (< v2.0.0): legacy documentation
- Core documentation: webklex/php-imap
- Wiki: php-imap wiki
Installation
1.) Install the Laravel IMAP package by running the following command:
1.1.) If you are getting errors or having some other issue, please follow step 1. - 1.1 here.
1.2.) If you are having trouble with v2.0.0, please go ahead and create a new issue and perhaps try the latest v1.6.2 version:
2.) If you're using Laravel >= 5.5, package discovery will configure the service provider and Client
alias out of the box.
Otherwise, for Laravel <= 5.4, edit your config/app.php
file and:
-
add the following to the
providers
array: - add the following to the
aliases
array:
3.) Run the command below to publish the package config file config/imap.php:
Configuration
If you are planning to use a single account, you might want to add the following to
your .env
file.
Please see webklex/php-imap#Configuration and config/imap.php for a detailed list of all available config options.
Usage
Basic usage example
This is a basic example, which will echo out all Mails within all imap folders and will move every message into INBOX.read. Please be aware that this should not be tested in real life and is only meant to gives an impression on how things work.
Please see webklex/php-imap#Table of Contents for more detail and further examples.
Facade
If you use the Facade \Webklex\IMAP\Facades\Client::class,
please start by selecting an in config/imap.php defined account first followed by
Client::connect()
to establish an authenticated connection:
View examples
You can find a few blade and mask examples under /examples.
Idle
Every time a new message is received, the server will notify the client and return the new message.
The callback and Webklex\IMAP\Events\MessageNewEvent($message)
event get fired by every new incoming email.
oAuth
Please take a look at the wiki article for gmail / google mail setup.
Basic oAuth example:
Events
The following events are available:
Webklex\IMAP\Events\MessageNewEvent($message)
— can get triggered byFolder::idle
Webklex\IMAP\Events\MessageDeletedEvent($message)
— triggered byMessage::delete
Webklex\IMAP\Events\MessageRestoredEvent($message)
— triggered byMessage::restore
Webklex\IMAP\Events\MessageMovedEvent($old_message, $new_message)
— triggered byMessage::move
Webklex\IMAP\Events\MessageCopiedEvent($old_message, $new_message)
— triggered byMessage::copy
Webklex\IMAP\Events\FlagNewEvent($flag)
— triggered byMessage::setFlag
Webklex\IMAP\Events\FlagDeletedEvent($flag)
— triggered byMessage::unsetFlag
Webklex\IMAP\Events\FolderNewEvent($folder)
— can get triggered byClient::createFolder
Webklex\IMAP\Events\FolderDeletedEvent($folder)
— triggered byFolder::delete
Webklex\IMAP\Events\FolderMovedEvent($old_folder, $new_folder)
— triggered byFolder::move
Additional integration information:
- https://laravel.com/docs/7.x/events#event-subscribers
- https://laravel.com/docs/5.2/events#event-subscribers
- https://github.com/Webklex/php-imap#events
Commands
Let's assume you want to run the imap idle process in the background of your server to automatically handle new messages. The following examples will show two major ways to archive this:
Event driven
Start by adding the following to your app/Console/Kernel.php
file:
Now register an event listener as described by the laravel docs. If you don't use the default account, or if you want to add some of your own magic, you'll need to create a custom command (see next section).
Finally test the command by running:
Custom Command
Create a new file like app/Console/Commands/CustomImapIdleCommand.php
and add the following:
..and add the following to your app/Console/Kernel.php
file:
Finally test the command by running:
Service setup
A basic systemd service can be setup by creating a service file like this:
..and adding:
You can now test the service by running:
Support
If you encounter any problems or if you find a bug, please don't hesitate to create a new issue. However please be aware that it might take some time to get an answer.
Off topic, rude or abusive issues will be deleted without any notice.
If you need immediate or commercial support, feel free to send me a mail at [email protected].
A little notice
If you write source code in your issue, please consider to format it correctly. This makes it so much nicer to read and people are more likely to comment and help :)
```php
echo 'your php code...';
```
will turn into:
Features & pull requests
Everyone can contribute to this project. Every pull request will be considered but it can also happen to be declined. To prevent unnecessary work, please consider to create a feature issue first, if you're planning to do bigger changes. Of course you can also create a new feature issue if you're just wishing a feature ;)
Known issues
Error | Solution |
---|---|
Kerberos error: No credentials cache file found (try running kinit) (...) | Uncomment "DISABLE_AUTHENTICATOR" inside and use the legacy-imap protocol config/imap.php |
Change log
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
Supporters
A special thanks to Jetbrains for supporting this project through their open source license program.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-imap with dependencies
ext-mbstring Version *
ext-iconv Version *
ext-fileinfo Version *
webklex/php-imap Version ^2.2
laravel/framework Version >=5.0.0