1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Helpers/Mail/GmailTransport.php
David Bomba 1b6ec9699a
Gmail Email via API (#3124)
* Working on GMail Driver

* working on custom Gmail Mail Provider

* Add total_taxes to quotes and recurring_*

* Implementation of new mailserviceprovider to allow native use of Mail:: with gmail email sending
2019-12-04 15:52:04 +11:00

68 lines
1.6 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Helpers\Mail;
use App\Libraries\MultiDB;
use App\Models\User;
use Dacastro4\LaravelGmail\Services\Message\Mail;
use Illuminate\Mail\Transport\Transport;
/**
* GmailTransport
*/
class GmailTransport extends Transport
{
/**
* The Gmail instance.
*
* @var \Dacastro4\LaravelGmail\Services\Message\Mail
*/
protected $gmail;
/**
* The GMail OAuth Token
* @var string token
*/
protected $token;
/**
* Create a new Gmail transport instance.
*
* @return void
*/
public function __construct(Mail $gmail, string $token)
{
$this->gmail = $gmail;
$this->token = $token
}
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
$this->beforeSendPerformed($message);
$this->gmail->using($this->token);
$this->gmail->to($message->getTo());
$this->gmail->from($message->getFrom());
$this->gmail->subject($message->getSubject());
//$this->gmail->message($message->getBody());
$this->gmail->message($message->toString());
$this->gmail->cc($message->getCc());
$this->gmail->bcc($message->getBcc());
$this->gmail->send();
$this->sendPerformed($message);
return $this->numberOfRecipients($message);
}