diff --git a/README.md b/README.md index 5451ab9..bd181e4 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,6 @@ First you need to add a new entry to the mail drivers array in your `config/mail 'client_id' => env('MICROSOFT_GRAPH_CLIENT_ID'), 'client_secret' => env('MICROSOFT_GRAPH_CLIENT_SECRET'), 'tenant_id' => env('MICROSOFT_GRAPH_TENANT_ID'), - 'from' => [ - 'address' => env('MAIL_FROM_ADDRESS'), - 'name' => env('MAIL_FROM_NAME'), - ], 'save_to_sent_items' => env('MAIL_SAVE_TO_SENT_ITEMS', false), ], ``` diff --git a/src/LaravelMsGraphMailServiceProvider.php b/src/LaravelMsGraphMailServiceProvider.php index 022bd87..527d4fa 100644 --- a/src/LaravelMsGraphMailServiceProvider.php +++ b/src/LaravelMsGraphMailServiceProvider.php @@ -25,8 +25,6 @@ public function configurePackage(Package $package): void public function boot(): void { Mail::extend('microsoft-graph', function (array $config): MicrosoftGraphTransport { - throw_if(blank($config['from']['address'] ?? []), new ConfigurationMissing('from.address')); - $accessTokenTtl = $config['access_token_ttl'] ?? 3000; if (! is_int($accessTokenTtl)) { throw new ConfigurationInvalid('access_token_ttl', $accessTokenTtl); diff --git a/tests/MicrosoftGraphTransportTest.php b/tests/MicrosoftGraphTransportTest.php index 5a3f54e..6d02d8d 100644 --- a/tests/MicrosoftGraphTransportTest.php +++ b/tests/MicrosoftGraphTransportTest.php @@ -18,13 +18,13 @@ 'client_id' => 'foo_client_id', 'client_secret' => 'foo_client_secret', 'tenant_id' => 'foo_tenant_id', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], 'save_to_sent_items' => null, ]); Config::set('mail.default', 'microsoft-graph'); + Config::set('mail.from', [ + 'address' => 'taylor@laravel.com', + 'name' => 'Taylor Otwell', + ]); Cache::set('microsoft-graph-api-access-token', 'foo_access_token', 3600); @@ -105,12 +105,12 @@ 'client_id' => 'foo_client_id', 'client_secret' => 'foo_client_secret', 'tenant_id' => 'foo_tenant_id', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ]); Config::set('mail.default', 'microsoft-graph'); + Config::set('mail.from', [ + 'address' => 'taylor@laravel.com', + 'name' => 'Taylor Otwell', + ]); Cache::set('microsoft-graph-api-access-token', 'foo_access_token', 3600); @@ -191,10 +191,6 @@ 'client_id' => 'foo_client_id', 'client_secret' => 'foo_client_secret', 'tenant_id' => 'foo_tenant_id', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ]); Config::set('mail.default', 'microsoft-graph'); @@ -227,10 +223,6 @@ 'client_id' => 'foo_client_id', 'client_secret' => 'foo_client_secret', 'tenant_id' => 'foo_tenant_id', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ]); Config::set('mail.default', 'microsoft-graph'); @@ -254,10 +246,6 @@ 'transport' => 'microsoft-graph', 'client_id' => 'foo_client_id', 'client_secret' => 'foo_client_secret', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ], new ConfigurationMissing('tenant_id'), ], @@ -267,10 +255,6 @@ 'tenant_id' => 123, 'client_id' => 'foo_client_id', 'client_secret' => 'foo_client_secret', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ], new ConfigurationInvalid('tenant_id', 123), ], @@ -279,10 +263,6 @@ 'transport' => 'microsoft-graph', 'tenant_id' => 'foo_tenant_id', 'client_secret' => 'foo_client_secret', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ], new ConfigurationMissing('client_id'), ], @@ -292,10 +272,6 @@ 'tenant_id' => 'foo_tenant_id', 'client_id' => '', 'client_secret' => 'foo_client_secret', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ], new ConfigurationInvalid('client_id', ''), ], @@ -304,10 +280,6 @@ 'transport' => 'microsoft-graph', 'tenant_id' => 'foo_tenant_id', 'client_id' => 'foo_client_id', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ], new ConfigurationMissing('client_secret'), ], @@ -317,22 +289,9 @@ 'tenant_id' => 'foo_tenant_id', 'client_id' => 'foo_client_id', 'client_secret' => null, - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ], new ConfigurationInvalid('client_secret', null), ], - [ - [ - 'transport' => 'microsoft-graph', - 'tenant_id' => 'foo_tenant_id', - 'client_id' => 'foo_client_id', - 'client_secret' => 'foo_client_secret', - ], - new ConfigurationMissing('from.address'), - ], [ [ 'transport' => 'microsoft-graph', @@ -340,10 +299,6 @@ 'client_id' => 'foo_client_id', 'client_secret' => 'foo_client_secret', 'access_token_ttl' => false, - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ], new ConfigurationInvalid('access_token_ttl', false), ], @@ -355,10 +310,10 @@ 'client_id' => 'foo_client_id', 'client_secret' => 'foo_client_secret', 'tenant_id' => 'foo_tenant_id', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], + ]); + Config::set('mail.from', [ + 'address' => 'taylor@laravel.com', + 'name' => 'Taylor Otwell', ]); Config::set('mail.default', 'microsoft-graph'); Config::set('filesystems.default', 'local'); @@ -438,10 +393,6 @@ 'client_id' => 'foo_client_id', 'client_secret' => 'foo_client_secret', 'tenant_id' => 'foo_tenant_id', - 'from' => [ - 'address' => 'taylor@laravel.com', - 'name' => 'Taylor Otwell', - ], ]); Config::set('mail.default', 'microsoft-graph');