1. Go to this page and download the library: Download medeirosrafael/laravel-imap library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php
use Webklex\IMAP\Client;
$oClient = new Client([
'host' => 'somehost.com',
'port' => 993,
'encryption' => 'ssl',
'validate_cert' => true,
'username' => 'username',
'password' => 'password',
]);
//Connect to the IMAP Server
$oClient->connect();
//Get all Mailboxes
$aMailboxes = $oClient->getFolders();
//Loop through every Mailbox
/** @var \Webklex\IMAP\Folder $oMailbox */
foreach($aMailboxes as $oMailbox){
//Get all Messages of the current Mailbox
/** @var \Webklex\IMAP\Message $oMessage */
foreach($oMailbox->getMessages() as $oMessage){
echo $oMessage->subject.'<br />';
echo 'Attachments: '.$oMessage->getAttachments()->count().'<br />';
echo $oMessage->getHTMLBody(true);
//Move the current Message to 'INBOX.read'
if($oMessage->moveToFolder('INBOX.read') == true){
echo 'Message has ben moved';
}else{
echo 'Message could not be moved';
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.