PHP code example of innoge / laravel-msgraph-mailbox
1. Go to this page and download the library: Download innoge/laravel-msgraph-mailbox 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/ */
use InnoGE\LaravelMsGraphMailbox\Enums\WellKnownFolder;
use InnoGE\LaravelMsGraphMailbox\Events\MessageReceived;
use InnoGE\LaravelMsGraphMailbox\Events\MessageRemoved;
'mailboxes' => [
'[email protected]' => [
'folders' => [WellKnownFolder::Inbox, 'Support/Escalations'],
'events' => [MessageReceived::class, MessageRemoved::class],
],
],
use InnoGE\LaravelMsGraphMailbox\Facades\Mailbox;
Mailbox::observe(fn () => Team::pluck('support_mailbox'));
use Illuminate\Support\Facades\Schedule;
Schedule::command('msgraph-mailbox:subscribe')->hourly()->onOneServer()->withoutOverlapping();
Schedule::command('msgraph-mailbox:sync')->everyFifteenMinutes()->onOneServer();
use InnoGE\LaravelMsGraphMailbox\Enums\FlagStatus;
use InnoGE\LaravelMsGraphMailbox\Enums\WellKnownFolder;
$message->archive();
$message->move('Support/Done');
$message->move('Support/Done', createMissing: true);
$message->copy(WellKnownFolder::Inbox); // Returns the copy
$message->markRead();
$message->markUnread();
$message->flag(FlagStatus::Complete);
$message->unflag();
$message->categorize('Customer', 'Urgent'); // Adds categories
$message->setCategories(['Customer']); // Replaces all categories
$message->delete(); // Moves the message to Deleted Items
$message->permanentDelete();
use InnoGE\LaravelMsGraphMailbox\Jobs\MoveMessage;
MoveMessage::dispatch('[email protected]', $id, WellKnownFolder::Archive);
use InnoGE\LaravelMsGraphMailbox\Jobs\Middleware\ThrottleGraphRequests;
public function middleware(MessageReceived $event): array
{
return [new ThrottleGraphRequests($event->mailbox)];
}