1. Go to this page and download the library: Download dacastro4/laravel-gmail 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/ */
dacastro4 / laravel-gmail example snippets
Route::get('/oauth/gmail', function (){
return LaravelGmail::redirect();
});
Route::get('/oauth/gmail/callback', function (){
LaravelGmail::makeToken();
return redirect()->to('/');
});
Route::get('/oauth/gmail/logout', function (){
LaravelGmail::logout(); //It returns exception if fails
return redirect()->to('/');
});
php
$mailbox = new LaravelGmailClass(config(), $account->id);
// One watch per account + need reinit every 24h+
$mailbox->stopWatch('[email protected]');
// Set watch for topic
$rq = new \Google_Service_Gmail_WatchRequest();
$rq->setTopicName('projects/YOUR_PROJECT_ID/topics/gmail');
$mailbox->setWatch('[email protected]', $rq);
php
$historyList = (new LaravelGmailClass(config(), $account->id))
->historyList($data['emailAddress'], [
'startHistoryId' => $startHistoryId,
]);
foreach ($historyList->history as $chunk) {
foreach ($chunk->messages as $msg) {
...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.