Working on mail drivers

This commit is contained in:
David Bomba 2022-06-24 13:15:56 +10:00
parent add5a9d9f7
commit ff783804ff
5 changed files with 83 additions and 43 deletions

View File

@ -11,9 +11,7 @@
namespace App\Providers; namespace App\Providers;
use App\Helpers\Mail\GmailTransportManager;
use App\Utils\CssInlinerPlugin; use App\Utils\CssInlinerPlugin;
use Coconuts\Mail\PostmarkTransport;
use GuzzleHttp\Client as HttpClient; use GuzzleHttp\Client as HttpClient;
use Illuminate\Container\Container; use Illuminate\Container\Container;
use Illuminate\Mail\MailServiceProvider as MailProvider; use Illuminate\Mail\MailServiceProvider as MailProvider;
@ -21,54 +19,30 @@ use Illuminate\Mail\TransportManager;
class MailServiceProvider extends MailProvider class MailServiceProvider extends MailProvider
{ {
public function register()
{
$this->registerIlluminateMailer();
}
public function boot() public function boot()
{ {
// app('mail.manager')->getSymfonyTransport()->registerPlugin($this->app->make(CssInlinerPlugin::class)); // app('mail.manager')->getSymfonyTransport()->registerPlugin($this->app->make(CssInlinerPlugin::class));
} }
protected function registerIlluminateMailer() /**
* Register the service provider.
*
* @return void
*/
public function register()
{ {
// //this is not octane safe $this->registerIlluminateMailer();
$this->app->singleton('mail.manager', function ($app) { $this->registerMarkdownRenderer();
return new GmailTransportManager($app);
});
//this is octane ready - but is untested
// $this->app->bind('mail.manager', function ($app){
// return new GmailTransportManager($app);
// });
$this->app->bind('mailer', function ($app) {
return $app->make('mail.manager')->mailer();
});
$this->app['mail.manager']->extend('cocopostmark', function () {
return new PostmarkTransport(
$this->guzzle(config('postmark.guzzle', [])),
config('postmark.secret')
);
});
} }
protected function guzzle(array $config): HttpClient public function registerGmailApiMailer()
{ {
return new HttpClient(array_merge($config, [
'base_uri' => empty($config['base_uri'])
? 'https://api.postmarkapp.com'
: $config['base_uri'],
]));
} }
public function provides() public function registerMicrosoftMailer()
{ {
return [
'mail.manager',
'mailer',
];
} }
} }

View File

@ -354,7 +354,7 @@ trait MakesInvoiceValues
$data[$key][$table_type.'.tax3'] = &$data[$key][$table_type.'.tax_rate3']; $data[$key][$table_type.'.tax3'] = &$data[$key][$table_type.'.tax_rate3'];
} }
$data[$key]['task_id'] = $item->task_id; $data[$key]['task_id'] = property_exists($item, 'task_id') ? $item->task_id : '';
} }
return $data; return $data;

View File

@ -84,11 +84,12 @@
"square/square": "13.0.0.20210721", "square/square": "13.0.0.20210721",
"stripe/stripe-php": "^7.50", "stripe/stripe-php": "^7.50",
"symfony/http-client": "^6.0", "symfony/http-client": "^6.0",
"symfony/mailgun-mailer": "^6.1",
"symfony/postmark-mailer": "^6.1",
"tijsverkoyen/css-to-inline-styles": "^2.2", "tijsverkoyen/css-to-inline-styles": "^2.2",
"turbo124/beacon": "^1.2", "turbo124/beacon": "^1.2",
"webpatser/laravel-countries": "dev-master#75992ad", "webpatser/laravel-countries": "dev-master#75992ad",
"wepay/php-sdk": "^0.3", "wepay/php-sdk": "^0.3"
"symfony/postmark-mailer": "^6.0"
}, },
"require-dev": { "require-dev": {
"php": "^7.4|^8.0", "php": "^7.4|^8.0",

67
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "6876460f0cb90da2bc3e8b03d6c270b9", "content-hash": "9c21b79c57e5ddfdd7c98a7b69773bd3",
"packages": [ "packages": [
{ {
"name": "afosto/yaac", "name": "afosto/yaac",
@ -9389,6 +9389,71 @@
], ],
"time": "2022-06-06T19:15:01+00:00" "time": "2022-06-06T19:15:01+00:00"
}, },
{
"name": "symfony/mailgun-mailer",
"version": "v6.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/mailgun-mailer.git",
"reference": "44d3c15049d84f5165917a6190f06adbe64d71dd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mailgun-mailer/zipball/44d3c15049d84f5165917a6190f06adbe64d71dd",
"reference": "44d3c15049d84f5165917a6190f06adbe64d71dd",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/mailer": "^5.4|^6.0"
},
"require-dev": {
"symfony/http-client": "^5.4|^6.0"
},
"type": "symfony-mailer-bridge",
"autoload": {
"psr-4": {
"Symfony\\Component\\Mailer\\Bridge\\Mailgun\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Mailgun Mailer Bridge",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/mailgun-mailer/tree/v6.1.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-04-01T07:15:35+00:00"
},
{ {
"name": "symfony/mime", "name": "symfony/mime",
"version": "v6.1.1", "version": "v6.1.1",

View File

@ -169,7 +169,7 @@ return [
Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class, App\Providers\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class, Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class,