Package Data | |
---|---|
Maintainer Username: | niltonmelox |
Maintainer Contact: | martijn@wagena.com (Martijn Wagena) |
Package Create Date: | 2017-05-13 |
Package Last Update: | 2017-05-16 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-17 03:06:20 |
Package Statistics | |
---|---|
Total Downloads: | 516 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 3 |
Total Open Issues: | 1 |
Setup the api:
Initiate the Gmail class
$gmail = new Gmail();
$gmail->getAuthUrl();
Use the returned code from the previous call to create a access + refresh token
$gmail->makeAccessToken($code);
Initiate connection
$gmail = MartijnWagena\Gmail\Mail::create()
->setAccessToken($access_token, $refresh_token)
->setStartDate($date);
Check if token refresh needed
$gmail->isAccessTokenExpired();
Fetch all messages starting from the 'setStartDate', you only receive the ids of the messages
$gmail->fetch();
To fetch details of a message, use the code below
$gmail->getMessage($id, $threadId);
Send mails with the api
$gmail = MartijnWagena\Gmail\Send::create()->setAccessToken($access_token, $refresh_token);
$gmail->sendMail(
[['email' => 'name@mail.com']],
[['email' => 'name2@mail.com']],
[['email' => 'name3@mail.com']],
'your subject',
'your message body',
'inreplytomessageId',
[] // array of attachments of type File
);
$gmail = MartijnWagena\Gmail::create()->setAccessToken($access_token, $refresh_token);
$gmail->revokeAccess();