diff --git a/app/Helpers/Mail/GmailTransport.php b/app/Helpers/Mail/GmailTransport.php index 0fed18076486..b7d3c0d77419 100644 --- a/app/Helpers/Mail/GmailTransport.php +++ b/app/Helpers/Mail/GmailTransport.php @@ -11,10 +11,9 @@ namespace App\Helpers\Mail; -use App\Models\User; -use App\Utils\TempFile; -use Dacastro4\LaravelGmail\Facade\LaravelGmail; -use Dacastro4\LaravelGmail\Services\Message\Mail; +use Google\Service\Gmail; +use Google\Service\Gmail\Message; +use Google\Client; use Symfony\Component\Mailer\SentMessage; use Symfony\Component\Mailer\Transport\AbstractTransport; use Symfony\Component\Mime\MessageConverter; @@ -24,14 +23,6 @@ use Symfony\Component\Mime\MessageConverter; */ class GmailTransport extends AbstractTransport { - /** - * The Gmail instance. - * - * @var Mail - */ - public $gmail; - - public $body; /** * Create a new Gmail transport instance. @@ -42,10 +33,6 @@ class GmailTransport extends AbstractTransport public function __construct() { parent::__construct(); - - $this->gmail = new Mail; - $this->body = new \Google\Service\Gmail\Message(); - } protected function doSend(SentMessage $message): void @@ -55,38 +42,27 @@ class GmailTransport extends AbstractTransport $token = $message->getHeaders()->get('GmailToken')->getValue(); $message->getHeaders()->remove('GmailToken'); - // $this->beforeSendPerformed($message); - $this->gmail->using($token); - $this->gmail->to($message->getTo()[0]->getAddress(), $message->getTo()[0]->getName()); - $this->gmail->from($message->getFrom()[0]->getAddress(), $message->getFrom()[0]->getName()); + $client = new Client(); + $client->setClientId(config('ninja.auth.google.client_id')); + $client->setClientSecret(config('ninja.auth.google.client_secret')); + $client->setAccessToken($token); + + $service = new Gmail($client); + $body = new Message(); + $body->setRaw($this->base64_encode($message->toString())); - $this->gmail->subject($message->getSubject()); - $this->gmail->message($message->getHtmlBody()); - $this->gmail->cc($message->getCc()); - - if(is_array($message->getBcc())) - $this->gmail->bcc(array_keys($message->getBcc())); - - foreach ($message->getAttachments() as $child) - { - - if($child->getContentType() != 'text/plain') - { - - $this->gmail->attach(TempFile::filePath($child->getBody(), $child->getName() )); - - } - - } - - $this->gmail->send(); - // $this->gmail->service->users_messages->send('me', $this->body,[]); + $service->users_messages->send('me', $body, []); } - public function __toString(): string + private function base64_encode($data) + { + return rtrim(strtr(base64_encode($data), ['+' => '-', '/' => '_']), '='); + } + + public function __toString(): string { return 'gmail'; } diff --git a/composer.json b/composer.json index 3b2a40603e67..12020a43d6bb 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,6 @@ "braintree/braintree_php": "^6.0", "checkout/checkout-sdk-php": "^2.5", "cleverit/ubl_invoice": "^1.3", - "dacastro4/laravel-gmail": "^6.0", "doctrine/dbal": "^3.0", "eway/eway-rapid-php": "^1.3", "fakerphp/faker": "^1.14", diff --git a/composer.lock b/composer.lock index 2d4da080fbdb..9f997c4e4596 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c90d978b81787218232a3cb4d19b2b98", + "content-hash": "9553e30992e58b8dd7c54229a209edba", "packages": [ { "name": "afosto/yaac", @@ -378,16 +378,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.229.2", + "version": "3.231.2", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "142a872fd7172bf5d067f4e30e4f89593296fc8f" + "reference": "9a7c2a8c4b7f95074749e1a7b575e6b4486bdcab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/142a872fd7172bf5d067f4e30e4f89593296fc8f", - "reference": "142a872fd7172bf5d067f4e30e4f89593296fc8f", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/9a7c2a8c4b7f95074749e1a7b575e6b4486bdcab", + "reference": "9a7c2a8c4b7f95074749e1a7b575e6b4486bdcab", "shasum": "" }, "require": { @@ -405,6 +405,7 @@ "andrewsville/php-token-reflection": "^1.4", "aws/aws-php-sns-message-validator": "~1.0", "behat/behat": "~3.0", + "composer/composer": "^1.10.22", "doctrine/cache": "~1.4", "ext-dom": "*", "ext-openssl": "*", @@ -463,9 +464,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.229.2" + "source": "https://github.com/aws/aws-sdk-php/tree/3.231.2" }, - "time": "2022-07-01T18:16:42+00:00" + "time": "2022-07-08T18:16:11+00:00" }, { "name": "bacon/bacon-qr-code", @@ -951,76 +952,6 @@ ], "time": "2022-05-24T11:56:16+00:00" }, - { - "name": "dacastro4/laravel-gmail", - "version": "v6.0", - "source": { - "type": "git", - "url": "https://github.com/dacastro4/laravel-gmail.git", - "reference": "6d6a447fb0404def74d5e7f275d37446aaa70345" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dacastro4/laravel-gmail/zipball/6d6a447fb0404def74d5e7f275d37446aaa70345", - "reference": "6d6a447fb0404def74d5e7f275d37446aaa70345", - "shasum": "" - }, - "require": { - "google/apiclient": "^2.5", - "illuminate/auth": "~5.8|^6.0|^7.0|^8.0|^9.0", - "illuminate/config": "~5.8|^6.0|^7.0|^8.0|^9.0", - "illuminate/database": "~5.8|^6.0|^7.0|^8.0|^9.0", - "illuminate/routing": "~5.8|^6.0|^7.0|^8.0|^9.0", - "illuminate/session": "~5.8|^6.0|^7.0|^8.0|^9.0", - "illuminate/support": "~5.8|^6.0|^7.0|^8.0|^9.0", - "php": "^7.4|^8.0", - "swiftmailer/swiftmailer": "~5.8|^6.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "orchestra/testbench": "^4.0|^5.0|^6.0", - "phpunit/phpunit": "^9.3", - "squizlabs/php_codesniffer": "~3.4" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Dacastro4\\LaravelGmail\\LaravelGmailServiceProvider" - ], - "aliases": { - "LaravelGmail": "Dacastro4\\LaravelGmail\\Facade\\LaravelGmail" - } - } - }, - "autoload": { - "psr-4": { - "Dacastro4\\LaravelGmail\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Daniel Castro", - "email": "danielcastro04@gmail.com", - "homepage": "https://danielcastro.dev" - } - ], - "description": "Gmail API package for Laravel", - "keywords": [ - "api", - "gmail", - "laravel" - ], - "support": { - "issues": "https://github.com/dacastro4/laravel-gmail/issues", - "source": "https://github.com/dacastro4/laravel-gmail/tree/v6.0" - }, - "time": "2022-03-07T14:05:36+00:00" - }, { "name": "dasprid/enum", "version": "1.0.3", @@ -2038,16 +1969,16 @@ }, { "name": "gocardless/gocardless-pro", - "version": "4.17.0", + "version": "4.18.0", "source": { "type": "git", "url": "https://github.com/gocardless/gocardless-pro-php.git", - "reference": "59ccdcbfbbf1a18b55c749ed121137dce6d6f3ae" + "reference": "dee046abbb7a37ef0a60bb03e2a467afc79a92a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/gocardless/gocardless-pro-php/zipball/59ccdcbfbbf1a18b55c749ed121137dce6d6f3ae", - "reference": "59ccdcbfbbf1a18b55c749ed121137dce6d6f3ae", + "url": "https://api.github.com/repos/gocardless/gocardless-pro-php/zipball/dee046abbb7a37ef0a60bb03e2a467afc79a92a5", + "reference": "dee046abbb7a37ef0a60bb03e2a467afc79a92a5", "shasum": "" }, "require": { @@ -2087,9 +2018,9 @@ ], "support": { "issues": "https://github.com/gocardless/gocardless-pro-php/issues", - "source": "https://github.com/gocardless/gocardless-pro-php/tree/v4.17.0" + "source": "https://github.com/gocardless/gocardless-pro-php/tree/v4.18.0" }, - "time": "2022-06-29T12:55:58+00:00" + "time": "2022-07-08T14:38:42+00:00" }, { "name": "google/apiclient", @@ -2163,16 +2094,16 @@ }, { "name": "google/apiclient-services", - "version": "v0.256.0", + "version": "v0.257.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "122e51021eb19b53f831904918460671d1e7259d" + "reference": "ae109202ee831a1fb70ba824181852e6179c848b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/122e51021eb19b53f831904918460671d1e7259d", - "reference": "122e51021eb19b53f831904918460671d1e7259d", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/ae109202ee831a1fb70ba824181852e6179c848b", + "reference": "ae109202ee831a1fb70ba824181852e6179c848b", "shasum": "" }, "require": { @@ -2201,9 +2132,9 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.256.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.257.0" }, - "time": "2022-07-04T01:10:37+00:00" + "time": "2022-07-08T01:28:13+00:00" }, { "name": "google/auth", @@ -4754,16 +4685,16 @@ }, { "name": "microsoft/microsoft-graph", - "version": "1.70.0", + "version": "1.71.0", "source": { "type": "git", "url": "https://github.com/microsoftgraph/msgraph-sdk-php.git", - "reference": "7d85293be037c4a2891a03cb953eb204bf68387e" + "reference": "f17ae778614d6ebf326d33292d09519d39b017a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/microsoftgraph/msgraph-sdk-php/zipball/7d85293be037c4a2891a03cb953eb204bf68387e", - "reference": "7d85293be037c4a2891a03cb953eb204bf68387e", + "url": "https://api.github.com/repos/microsoftgraph/msgraph-sdk-php/zipball/f17ae778614d6ebf326d33292d09519d39b017a8", + "reference": "f17ae778614d6ebf326d33292d09519d39b017a8", "shasum": "" }, "require": { @@ -4799,9 +4730,9 @@ "homepage": "https://developer.microsoft.com/en-us/graph", "support": { "issues": "https://github.com/microsoftgraph/msgraph-sdk-php/issues", - "source": "https://github.com/microsoftgraph/msgraph-sdk-php/tree/1.70.0" + "source": "https://github.com/microsoftgraph/msgraph-sdk-php/tree/1.71.0" }, - "time": "2022-06-21T13:37:02+00:00" + "time": "2022-07-07T10:04:08+00:00" }, { "name": "mollie/mollie-api-php", @@ -7172,16 +7103,16 @@ }, { "name": "psy/psysh", - "version": "v0.11.6", + "version": "v0.11.7", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "3f5b5f8aaa979fbd0d1783173f4c82ad529fe621" + "reference": "77fc7270031fbc28f9a7bea31385da5c4855cb7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/3f5b5f8aaa979fbd0d1783173f4c82ad529fe621", - "reference": "3f5b5f8aaa979fbd0d1783173f4c82ad529fe621", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/77fc7270031fbc28f9a7bea31385da5c4855cb7a", + "reference": "77fc7270031fbc28f9a7bea31385da5c4855cb7a", "shasum": "" }, "require": { @@ -7242,9 +7173,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.11.6" + "source": "https://github.com/bobthecow/psysh/tree/v0.11.7" }, - "time": "2022-07-03T16:40:23+00:00" + "time": "2022-07-07T13:49:11+00:00" }, { "name": "ralouphie/getallheaders", @@ -8455,82 +8386,6 @@ }, "time": "2022-05-05T17:18:02+00:00" }, - { - "name": "swiftmailer/swiftmailer", - "version": "v6.3.0", - "source": { - "type": "git", - "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "8a5d5072dca8f48460fce2f4131fcc495eec654c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/8a5d5072dca8f48460fce2f4131fcc495eec654c", - "reference": "8a5d5072dca8f48460fce2f4131fcc495eec654c", - "shasum": "" - }, - "require": { - "egulias/email-validator": "^2.0|^3.1", - "php": ">=7.0.0", - "symfony/polyfill-iconv": "^1.0", - "symfony/polyfill-intl-idn": "^1.10", - "symfony/polyfill-mbstring": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "symfony/phpunit-bridge": "^4.4|^5.4" - }, - "suggest": { - "ext-intl": "Needed to support internationalized email addresses" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.2-dev" - } - }, - "autoload": { - "files": [ - "lib/swift_required.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Chris Corbyn" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Swiftmailer, free feature-rich PHP mailer", - "homepage": "https://swiftmailer.symfony.com", - "keywords": [ - "email", - "mail", - "mailer" - ], - "support": { - "issues": "https://github.com/swiftmailer/swiftmailer/issues", - "source": "https://github.com/swiftmailer/swiftmailer/tree/v6.3.0" - }, - "funding": [ - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/swiftmailer/swiftmailer", - "type": "tidelift" - } - ], - "abandoned": "symfony/mailer", - "time": "2021-10-18T15:26:12+00:00" - }, { "name": "symfony/console", "version": "v6.1.2", @@ -9835,89 +9690,6 @@ ], "time": "2022-05-24T11:49:31+00:00" }, - { - "name": "symfony/polyfill-iconv", - "version": "v1.26.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "143f1881e655bebca1312722af8068de235ae5dc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/143f1881e655bebca1312722af8068de235ae5dc", - "reference": "143f1881e655bebca1312722af8068de235ae5dc", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-iconv": "*" - }, - "suggest": { - "ext-iconv": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Iconv\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Iconv extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "iconv", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-iconv/tree/v1.26.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-24T11:49:31+00:00" - }, { "name": "symfony/polyfill-intl-grapheme", "version": "v1.26.0", @@ -15242,5 +15014,5 @@ "platform-dev": { "php": "^7.4|^8.0" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.3.0" }