Skip to content

Commit 41df466

Browse files
author
Malte Goldenbaum
committed
Examples added
1 parent e45a196 commit 41df466

File tree

1 file changed

+64
-4
lines changed

1 file changed

+64
-4
lines changed

README.md

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ Add the service provider to the providers array in `config/app.php`.
2626
];
2727
```
2828

29+
If you are planning to use a single account, you might want to add the following to
30+
your .env file.
31+
32+
```
33+
IMAP_HOST=somehost.com
34+
IMAP_PORT=993
35+
IMAP_ENCRYPTION=ssl
36+
IMAP_VALIDATE_CERT=true
37+
38+
IMAP_PASSWORD=secret
39+
```
40+
41+
The following encryption methods are supported:
42+
```
43+
false - Disable encryption
44+
ssl - Use SSL
45+
tls - Use TLS
46+
47+
```
48+
2949
## Publishing
3050

3151
You can publish everything at once
@@ -40,10 +60,6 @@ or you can publish groups individually.
4060
php artisan vendor:publish --provider="Webklex\IMAP\Providers\LaravelServiceProvider" --tag="config"
4161
```
4262

43-
## Usage
44-
45-
[...]
46-
4763
Access the IMAP Client by its Facade (Webklex\IMAP\Facades\Client).
4864
Therefor you might want to add an alias to the aliases array within the `config/app.php` file.
4965

@@ -53,6 +69,50 @@ Therefor you might want to add an alias to the aliases array within the `config/
5369
];
5470
```
5571

72+
## Usage
73+
74+
This library is designed to handle the native php imap functions more easily and to be
75+
able to integrate this package within your current laravel installation.
76+
77+
Here is a basic example, which will echo out all Mails within all imap folders
78+
and will move every message into INBOX.read. Please be aware that this should not ben
79+
tested in real live but it gives an impression on how things work.
80+
81+
``` php
82+
use Webklex\IMAP\Client;
83+
84+
//Connect to the IMAP Server
85+
$oClient = new Client([
86+
'host' => 'somehost.com',
87+
'port' => 993,
88+
'encryption' => 'ssl',
89+
'validate_cert' => true,
90+
'username' => 'username',
91+
'password' => 'password',
92+
]);
93+
$oClient->connect();
94+
95+
//Get all Mailboxes
96+
$aMailboxes = $oClient->getFolders();
97+
98+
//Loop through every Mailbox
99+
foreach($aMailboxes as $oMailboxes){
100+
101+
//Get all Messages of the current Mailbox
102+
foreach($oMailbox->getMessages() as $oMessage){
103+
echo $oMessage->subject.'<br />';
104+
echo $oMessage->getHTMLBody(true);
105+
106+
//Move the current Message to 'INBOX.read'
107+
if($oMessage->moveToFolder('INBOX.read') == true){
108+
echo 'Message has ben moved';
109+
}else{
110+
echo 'Message could not be moved';
111+
}
112+
}
113+
}
114+
```
115+
56116
## Change log
57117

58118
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

0 commit comments

Comments
 (0)