11# IMAP Library for Laravel
22
33[ ![ Latest Version on Packagist] [ ico-version ]] [ link-packagist ]
4- [ ![ Software License] [ ico-license ]] ( LICENSE.md )
4+ [ ![ Software License] [ ico-license ]] [ link-license ]
55[ ![ Build Status] [ ico-build ]] [ link-scrutinizer ]
66[ ![ Code quality] [ ico-quality ]] [ link-scrutinizer ]
77[ ![ Total Downloads] [ ico-downloads ]] [ link-downloads ]
88[ ![ Hits] [ ico-hits ]] [ link-hits ]
99
10- ## Description
1110
11+ ## Description
1212Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol
13- into your ** Laravel** app.
13+ into your ** Laravel** app. This enables your app to not only respond to new emails but also allows it to
14+ read and parse existing mails and much more.
1415
1516> If you want to use this library outside of Laravel, please head over to [ webklex/php-imap] ( https://github.com/Webklex/php-imap )
17+ > for a standalone version.
1618
17- Documentation < v2.0.0: [ legacy documentation] ( https://github.com/Webklex/laravel-imap/tree/1.6.2#table-of-contents )
18-
19- Core documentation and wiki: [ core documentation] ( https://github.com/Webklex/php-imap ) ,
20- [ wiki] ( https://github.com/Webklex/php-imap/wiki )
2119
2220## Table of Contents
21+ - [ Documentations] ( #documentations )
2322- [ Installation] ( #installation )
2423- [ Configuration] ( #configuration )
2524- [ Usage] ( #usage )
@@ -36,42 +35,48 @@ Core documentation and wiki: [core documentation](https://github.com/Webklex/php
3635- [ Supporters] ( #supporters )
3736- [ License] ( #license )
3837
39- Additional information can be found here: [ webklex/php-imap] ( https://github.com/Webklex/php-imap ) .
38+
39+ ## Documentations
40+ - Legacy (< v2.0.0): [ legacy documentation] ( https://github.com/Webklex/laravel-imap/tree/1.6.2#table-of-contents )
41+ - Core documentation: [ webklex/php-imap] ( https://github.com/Webklex/php-imap )
42+ - Wiki: [ php-imap wiki] ( https://github.com/Webklex/php-imap/wiki )
43+
4044
4145## Installation
42- 1 . Install the Laravel IMAP package by running the following command:
46+ 1.) Install the Laravel IMAP package by running the following command:
4347``` shell
4448composer require webklex/laravel-imap
4549```
4650
47- 1.1 If you are getting errors or having some other issue, please follow step 1. - 1.1 under
48- [ webklex/php-imap > Installation ] ( https://github.com/Webklex/php-imap#installation ) .
51+ 1.1.) If you are getting errors or having some other issue, please follow step 1. - 1.1
52+ [ here ] ( https://github.com/Webklex/php-imap#installation ) .
4953
50- 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:
54+ 1.2.) If you are having trouble with v2.0.0, please go ahead and create a new issue and perhaps
55+ try the latest v1.6.2 version:
5156``` shell
5257composer require webklex/laravel-imap:1.6.2
5358```
5459
55- 2 . If you're using Laravel >= 5.5, package discovery will configure the service provider and ` Client ` alias out of the box.
56- Otherwise, for Laravel <= 5.4, edit your ` config/app.php ` file and:
57- - add the following to the ` providers ` array:
58- ``` php
59- Webklex\IMAP\Providers\LaravelServiceProvider::class,
60- ```
61- - add the following to the `aliases` array:
62- ```php
63- 'Client' => Webklex\IMAP\Facades\Client::class,
64- ```
65-
66- 3. Run the command below to publish the package config file [config/imap.php](src/config/imap.php):
60+ 2.) If you're using Laravel >= 5.5, package discovery will configure the service provider and ` Client ` alias out of the box.
61+ Otherwise, for Laravel <= 5.4, edit your ` config/app.php ` file and:
62+ - add the following to the ` providers ` array:
63+ ``` php
64+ Webklex\IMAP\Providers\LaravelServiceProvider::class,
65+ ```
66+ - add the following to the ` aliases ` array:
67+ ``` php
68+ 'Client' => Webklex\IMAP\Facades\Client::class,
69+ ```
70+
71+ 3.) Run the command below to publish the package config file [ config/imap.php] ( src/config/imap.php ) :
6772``` shell
6873php artisan vendor:publish --provider=" Webklex\IMAP\Providers\LaravelServiceProvider"
6974```
7075
76+
7177## Configuration
7278If you are planning to use a single account, you might want to add the following to
7379your ` .env ` file.
74-
7580```
7681IMAP_HOST=somehost.com
7782IMAP_PORT=993
@@ -83,19 +88,20 @@ IMAP_DEFAULT_ACCOUNT=default
8388IMAP_PROTOCOL=imap
8489```
8590
86- Please see [ webklex/php-imap > Configuration] ( https://github.com/Webklex/php-imap#configuration ) for a detailed list of
87- all available config options.
91+ Please see [ webklex/php-imap#Configuration] ( https://github.com/Webklex/php-imap#configuration ) and
92+ [ config/imap.php] ( src/config/imap.php ) for a detailed list of all available config options.
93+
8894
8995## Usage
9096#### Basic usage example
9197This is a basic example, which will echo out all Mails within all imap folders
9298and will move every message into INBOX.read. Please be aware that this should not be
93- tested in real live but it gives an impression on how things work.
99+ tested in real life and is only meant to gives an impression on how things work.
94100
95101``` php
96102use Webklex\PHPIMAP\Client;
97103
98- $oClient = new Client([
104+ $client = new Client([
99105 'host' => 'somehost.com',
100106 'port' => 993,
101107 'encryption' => 'ssl',
@@ -105,64 +111,59 @@ $oClient = new Client([
105111 'protocol' => 'imap'
106112]);
107113/* Alternative by using the Facade
108- $oClient = Webklex\IMAP\Facades\Client::account('default');
114+ $client = Webklex\IMAP\Facades\Client::account('default');
109115*/
110116
111117//Connect to the IMAP Server
112- $oClient ->connect();
118+ $client ->connect();
113119
114120//Get all Mailboxes
115- /** @var \Webklex\PHPIMAP\Support\FolderCollection $aFolder */
116- $aFolder = $oClient->getFolders();
121+ /** @var \Webklex\PHPIMAP\Support\FolderCollection $folders */
122+ $folders = $oClient->getFolders();
117123
118124//Loop through every Mailbox
119- /** @var \Webklex\PHPIMAP\Folder $oFolder */
120- foreach($aFolder as $oFolder ){
125+ /** @var \Webklex\PHPIMAP\Folder $folder */
126+ foreach($folders as $folder ){
121127
122128 //Get all Messages of the current Mailbox $oFolder
123- /** @var \Webklex\PHPIMAP\Support\MessageCollection $aMessage */
124- $aMessage = $oFolder ->messages()->all()->get();
129+ /** @var \Webklex\PHPIMAP\Support\MessageCollection $messages */
130+ $messages = $folder ->messages()->all()->get();
125131
126- /** @var \Webklex\PHPIMAP\Message $oMessage */
127- foreach($aMessage as $oMessage ){
128- echo $oMessage ->getSubject().'<br />';
129- echo 'Attachments: '.$oMessage ->getAttachments()->count().'<br />';
130- echo $oMessage ->getHTMLBody();
132+ /** @var \Webklex\PHPIMAP\Message $message */
133+ foreach($messages as $message ){
134+ echo $message ->getSubject().'<br />';
135+ echo 'Attachments: '.$message ->getAttachments()->count().'<br />';
136+ echo $message ->getHTMLBody();
131137
132138 //Move the current Message to 'INBOX.read'
133- if($oMessage ->moveToFolder('INBOX.read') == true){
139+ if($message ->moveToFolder('INBOX.read') == true){
134140 echo 'Message has ben moved';
135141 }else{
136142 echo 'Message could not be moved';
137143 }
138144 }
139145}
140146```
141- Please see [ webklex/php-imap > Table of Contents] ( https://github.com/Webklex/php-imap#table-of-contents ) for more detail.
147+ Please see [ webklex/php-imap#Table of Contents] ( https://github.com/Webklex/php-imap#table-of-contents ) for more detail
148+ and further examples.
149+
142150
143151#### Facade
144- If you use the Facade [ \Webklex\IMAP\Facades\Client::class] ( src/IMAP/Facades/Client.php ) please select an account first:
152+ If you use the Facade [ \Webklex\IMAP\Facades\Client::class] ( src/IMAP/Facades/Client.php ) ,
153+ please start by selecting an in [ config/imap.php] ( src/config/imap.php ) defined account first followed by
154+ ` Client::connect() ` to establish an authenticated connection:
145155
146156``` php
147157use Webklex\IMAP\Facades\Client;
148158
149- /** @var \Webklex\PHPIMAP\Client $oClient */
150- $oClient = Client::account('default');
151- $oClient ->connect();
159+ /** @var \Webklex\PHPIMAP\Client $client */
160+ $client = Client::account('default');
161+ $client ->connect();
152162```
153163
154164#### View examples
155- You can find a few blade examples under [ examples] ( examples ) .
156-
157- #### Fetch a specific message
158- Get a specific message by uid (Please note that the uid is not unique and can change):
165+ You can find a few blade and [ mask] ( https://github.com/Webklex/php-imap#masking ) examples under [ /examples] ( examples ) .
159166
160- ``` php
161- /** @var \Webklex\PHPIMAP\Folder $oFolder */
162-
163- /** @var \Webklex\PHPIMAP\Message $oMessage */
164- $oMessage = $oFolder->query()->getMessage($uid = 1);
165- ```
166167
167168#### Idle
168169Every time a new message is received, the server will notify the client and return the new message.
@@ -179,11 +180,13 @@ $folder->idle(function($message){
179180```
180181
181182#### oAuth
182- If you are using google mail or something similar, you might want to use oauth instead:
183+ If you are using google mail or something similar, you might have to use oauth instead:
183184
184185``` php
185- /** @var \Webklex\PHPIMAP\Client $oClient */
186- $oClient = new Client([
186+ use Webklex\PHPIMAP\Client;
187+
188+ /** @var \Webklex\PHPIMAP\Client $client */
189+ $client = new Client([
187190 'host' => 'imap.gmail.com',
188191 'port' => 993,
189192 'encryption' => 'ssl',
@@ -217,9 +220,12 @@ Additional integration information:
217220- https://github.com/Webklex/php-imap#events
218221
219222## Support
220- If you encounter any problems or if you find a bug, please don't hesitate to create a new [ issue] ( https://github.com/Webklex/laravel-imap/issues ) .
223+ If you encounter any problems or if you find a bug, please don't hesitate to create a new
224+ [ issue] ( https://github.com/Webklex/laravel-imap/issues ) .
221225However please be aware that it might take some time to get an answer.
222226
227+ Off topic, rude or abusive issues will be deleted without any notice.
228+
223229If you need
** immediate
** or
** commercial
** support, feel free to send me a mail at
[email protected] .
224230
225231##### A little notice
@@ -243,15 +249,13 @@ To prevent unnecessary work, please consider to create a [feature issue](https:/
243249first, if you're planning to do bigger changes. Of course you can also create a new [ feature issue] ( https://github.com/Webklex/laravel-imap/issues/new?template=feature_request.md )
244250if you're just wishing a feature ;)
245251
246- > Off topic, rude or abusive issues will be deleted without any notice.
247-
248252### Known issues
249253| Error | Solution |
250254| ------------------------------------------------------------------------- | ---------------------------------------------------------- |
251255| Kerberos error: No credentials cache file found (try running kinit) (...) | Uncomment "DISABLE_AUTHENTICATOR" inside and use the ` legacy-imap ` protocol ` config/imap.php ` |
252256
253257## Change log
254- Please see [ CHANGELOG] ( CHANGELOG.md ) for more information what has changed recently.
258+ Please see [ CHANGELOG] [ link-changelog ] for more information what has changed recently.
255259
256260## Security
257261If you discover any security related issues, please email
[email protected] instead of using the issue tracker.
@@ -266,13 +270,13 @@ A special thanks to Jetbrains for supporting this project through their [open so
266270[ ![ Jetbrains] [ png-jetbrains ]] [ link-jetbrains ]
267271
268272## License
269- The MIT License (MIT). Please see [ License File] ( LICENSE.md ) for more information.
273+ The MIT License (MIT). Please see [ License File] [ link-license ] for more information.
270274
271275[ ico-version ] : https://img.shields.io/packagist/v/webklex/laravel-imap.svg?style=flat-square
272276[ ico-license ] : https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
273277[ ico-travis ] : https://img.shields.io/travis/Webklex/laravel-imap/master.svg?style=flat-square
274278[ ico-downloads ] : https://img.shields.io/packagist/dt/Webklex/laravel-imap.svg?style=flat-square
275- [ ico-hits ] : https://hits.webklex.com/svg/webklex/laravel-imap?
279+ [ ico-hits ] : https://hits.webklex.com/svg/webklex/laravel-imap
276280[ ico-build ] : https://img.shields.io/scrutinizer/build/g/Webklex/laravel-imap/master?style=flat-square
277281[ ico-quality ] : https://img.shields.io/scrutinizer/quality/g/Webklex/laravel-imap/master?style=flat-square
278282[ png-jetbrains ] : https://www.webklex.com/jetbrains.png
@@ -284,4 +288,6 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
284288[ link-hits ] : https://hits.webklex.com
285289[ link-author ] : https://github.com/webklex
286290[ link-contributors ] : https://github.com/Webklex/laravel-imap/graphs/contributors
291+ [ link-license ] : https://github.com/Webklex/laravel-imap/blob/master/LICENSE
292+ [ link-changelog ] : https://github.com/Webklex/laravel-imap/blob/master/CHANGELOG.md
287293[ link-jetbrains ] : https://www.jetbrains.com
0 commit comments