Skip to content
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ composer.phar
composer.lock
.DS_Store
Thumbs.db
.idea
.idea
.history/
19 changes: 18 additions & 1 deletion src/Services/Message/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ class Mail extends GmailConnection

public $parts;

/**
* @var
*/
public $snippet;

/**
* @var Google_Service_Gmail
*/
Expand Down Expand Up @@ -130,6 +135,7 @@ protected function setMessage(\Google_Service_Gmail_Message $message)
$this->threadId = $message->getThreadId();
$this->historyId = $message->getHistoryId();
$this->payload = $message->getPayload();
$this->snippet = $message->getSnippet();
if ($this->payload) {
$this->parts = collect($this->payload->getParts());
}
Expand Down Expand Up @@ -231,6 +237,18 @@ public function getReplyTo()
return $this->getFrom($replyTo ? $replyTo : $this->getHeader('From'));
}

/**
* Returns the Snippet from the email
*
* @return string
*/
public function getSnippet()
{


return $this->snippet;
}

/**
* Returns array of name and email of each recipient
*
Expand Down Expand Up @@ -407,7 +425,6 @@ public function getPlainTextBody($raw = false)
public function getBody($type = 'text/plain')
{
$parts = $this->getAllParts($this->parts);

try {
if (!$parts->isEmpty()) {
foreach ($parts as $part) {
Expand Down
5 changes: 3 additions & 2 deletions src/Traits/Configurable.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function config($string = null)
} else {
return $config;
}

}

return null;
Expand Down Expand Up @@ -90,12 +89,14 @@ private function configApi()
{
$type = $this->_config['gmail.access_type'];
$approval_prompt = $this->_config['gmail.approval_prompt'];
$prompt = $this->_config['gmail.prompt'];

$this->setScopes($this->getUserScopes());

$this->setAccessType($type);

$this->setApprovalPrompt($approval_prompt);
$this->setPrompt($prompt);
}

public abstract function setScopes($scopes);
Expand Down Expand Up @@ -141,5 +142,5 @@ private function scopeMap($scope)
public abstract function setAccessType($type);

public abstract function setApprovalPrompt($approval);

public abstract function setPrompt($prompt);
}
14 changes: 14 additions & 0 deletions src/Traits/HasLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,18 @@ public function firstOrCreateLabel($userEmail, $newLabel)

return $service->users_labels->create($userEmail, $newLabel);
}

/**
* List the labels in the user's mailbox.
*
* @param $userEmail
*
* @return \Google\Service\Gmail\Label
*/
public function getLabel($userEmail, $id)
{
$service = new Google_Service_Gmail($this);

return $service->users_labels->get($userEmail, $id);
}
}
14 changes: 7 additions & 7 deletions src/Traits/Replyable.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ public function setHeader($header, $value)
$headers = $this->symfonyEmail->getHeaders();

$headers->addTextHeader($header, $value);

}

private function setReplySubject()
Expand Down Expand Up @@ -401,16 +400,18 @@ public abstract function getUser();
private function getMessageBody()
{
$body = new Google_Service_Gmail_Message();

$this->symfonyEmail
->from($this->fromAddress())
->to($this->toAddress())
->cc($this->returnCopies($this->cc))
->bcc($this->returnCopies($this->bcc))
->subject($this->subject)
->html($this->message)
->priority($this->priority);

if (!empty($this->cc)) {
$this->symfonyEmail->cc($this->returnCopies($this->cc));
}
if (!empty($this->bcc)) {
$this->symfonyEmail->bcc($this->returnCopies($this->bcc));
}
foreach ($this->attachments as $file) {
$this->symfonyEmail->attachFromPath($file);
}
Expand Down Expand Up @@ -438,7 +439,7 @@ public function returnCopies($cc)
return $final;
}

return [];
return "";
}

public function toAddress()
Expand Down Expand Up @@ -472,7 +473,6 @@ private function base64_encode($data)
public function send()
{
$body = $this->getMessageBody();

$this->setMessage($this->service->users_messages->send('me', $body, $this->parameters));

return $this;
Expand Down