Skip to content

Commit 96b86a1

Browse files
authored
Merge pull request #7 from mwlvandermaat/feature/save-to-sent-items-config
Added configurable option for save_to_sent_items
2 parents 391c939 + 61e126e commit 96b86a1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ You can install the package via composer:
1515
```bash
1616
composer require innoge/laravel-msgraph-mail
1717
```
18+
1819
### Compatibility
20+
1921
Laravel 10.x and 9.x are supported.
2022

2123
## Configuration
2224

2325
### Register the Azure App
2426

2527
### Microsoft Azure AD Configuration
28+
2629
I have written a detailed Blog Post how you can configure your Microsoft Azure AD Tenant. [Sending Mails with Laravel and Microsoft Office 365 the secure way](https://geisi.dev/blog/getting-rid-of-deprecated-microsoft-office-365-smtp-mail-sending)
2730

2831
### I want to figure it out on my own
@@ -50,12 +53,17 @@ First you need to add a new entry to the mail drivers array in your `config/mail
5053
'address' => env('MAIL_FROM_ADDRESS'),
5154
'name' => env('MAIL_FROM_NAME'),
5255
],
56+
'save_to_sent_items' => env('MAIL_SAVE_TO_SENT_ITEMS'),
5357
],
5458
```
5559

5660
For the `client_id`, `client_secret` and `tenant_id` you need to use the values from the Azure App you created in the
5761
previous step.
5862

63+
The `save_to_sent_items` option in Microsoft Graph refers to a parameter that determines whether a sent email should be saved to the sender's "Sent Items" folder within their mailbox. When this option is set to true, the email will be automatically saved to the "Sent Items" folder, providing a record of the communication. Conversely, when it's set to false, the email will not be saved to the "Sent Items" folder.
64+
65+
By default, the save_to_sent_items option is set to false, which means that emails sent through Microsoft Graph won't be saved in the sender's "Sent Items" folder unless explicitly specified otherwise. This behavior can be useful in scenarios where you might want more control over which emails are saved as sent items, perhaps to reduce clutter or ensure confidentiality.
66+
5967
Now you can switch your default mail driver to the new `microsoft-graph` driver by setting the env variable:
6068

6169
```dotenv
@@ -82,8 +90,8 @@ Please review [our security policy](../../security/policy) on how to report secu
8290

8391
## Credits
8492

85-
- [Tim Geisendoerfer](https://github.com/InnoGE)
86-
- [All Contributors](../../contributors)
93+
- [Tim Geisendoerfer](https://github.com/InnoGE)
94+
- [All Contributors](../../contributors)
8795

8896
## License
8997

src/MicrosoftGraphTransport.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function doSend(SentMessage $message): void
4848
'sender' => $this->transformEmailAddress($envelope->getSender()),
4949
'attachments' => $this->getAttachments($email),
5050
],
51-
'saveToSentItems' => false,
51+
'saveToSentItems' => config('mail.mailers.microsoft-graph.save_to_sent_items', false),
5252
];
5353

5454
$this->microsoftGraphApiService->sendMail($this->from, $payload);
@@ -86,7 +86,7 @@ protected function transformEmailAddress(Address $address): array
8686
protected function getRecipients(Email $email, Envelope $envelope): Collection
8787
{
8888
return collect($envelope->getRecipients())
89-
->filter(fn (Address $address) => ! in_array($address, array_merge($email->getCc(), $email->getBcc()), true));
89+
->filter(fn (Address $address) => !in_array($address, array_merge($email->getCc(), $email->getBcc()), true));
9090
}
9191

9292
protected function getAttachments(Email $email): array

0 commit comments

Comments
 (0)