Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
```
Expand Down
2 changes: 0 additions & 2 deletions src/LaravelMsGraphMailServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
73 changes: 12 additions & 61 deletions tests/MicrosoftGraphTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
'client_id' => 'foo_client_id',
'client_secret' => 'foo_client_secret',
'tenant_id' => 'foo_tenant_id',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
'save_to_sent_items' => null,
]);
Config::set('mail.default', 'microsoft-graph');
Config::set('mail.from', [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
]);

Cache::set('microsoft-graph-api-access-token', 'foo_access_token', 3600);

Expand Down Expand Up @@ -105,12 +105,12 @@
'client_id' => 'foo_client_id',
'client_secret' => 'foo_client_secret',
'tenant_id' => 'foo_tenant_id',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
]);
Config::set('mail.default', 'microsoft-graph');
Config::set('mail.from', [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
]);

Cache::set('microsoft-graph-api-access-token', 'foo_access_token', 3600);

Expand Down Expand Up @@ -191,10 +191,6 @@
'client_id' => 'foo_client_id',
'client_secret' => 'foo_client_secret',
'tenant_id' => 'foo_tenant_id',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
]);
Config::set('mail.default', 'microsoft-graph');

Expand Down Expand Up @@ -227,10 +223,6 @@
'client_id' => 'foo_client_id',
'client_secret' => 'foo_client_secret',
'tenant_id' => 'foo_tenant_id',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
]);
Config::set('mail.default', 'microsoft-graph');

Expand All @@ -254,10 +246,6 @@
'transport' => 'microsoft-graph',
'client_id' => 'foo_client_id',
'client_secret' => 'foo_client_secret',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
],
new ConfigurationMissing('tenant_id'),
],
Expand All @@ -267,10 +255,6 @@
'tenant_id' => 123,
'client_id' => 'foo_client_id',
'client_secret' => 'foo_client_secret',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
],
new ConfigurationInvalid('tenant_id', 123),
],
Expand All @@ -279,10 +263,6 @@
'transport' => 'microsoft-graph',
'tenant_id' => 'foo_tenant_id',
'client_secret' => 'foo_client_secret',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
],
new ConfigurationMissing('client_id'),
],
Expand All @@ -292,10 +272,6 @@
'tenant_id' => 'foo_tenant_id',
'client_id' => '',
'client_secret' => 'foo_client_secret',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
],
new ConfigurationInvalid('client_id', ''),
],
Expand All @@ -304,10 +280,6 @@
'transport' => 'microsoft-graph',
'tenant_id' => 'foo_tenant_id',
'client_id' => 'foo_client_id',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
],
new ConfigurationMissing('client_secret'),
],
Expand All @@ -317,33 +289,16 @@
'tenant_id' => 'foo_tenant_id',
'client_id' => 'foo_client_id',
'client_secret' => null,
'from' => [
'address' => '[email protected]',
'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',
'tenant_id' => 'foo_tenant_id',
'client_id' => 'foo_client_id',
'client_secret' => 'foo_client_secret',
'access_token_ttl' => false,
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
],
new ConfigurationInvalid('access_token_ttl', false),
],
Expand All @@ -355,10 +310,10 @@
'client_id' => 'foo_client_id',
'client_secret' => 'foo_client_secret',
'tenant_id' => 'foo_tenant_id',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
]);
Config::set('mail.from', [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
]);
Config::set('mail.default', 'microsoft-graph');
Config::set('filesystems.default', 'local');
Expand Down Expand Up @@ -438,10 +393,6 @@
'client_id' => 'foo_client_id',
'client_secret' => 'foo_client_secret',
'tenant_id' => 'foo_tenant_id',
'from' => [
'address' => '[email protected]',
'name' => 'Taylor Otwell',
],
]);
Config::set('mail.default', 'microsoft-graph');

Expand Down
Loading