Skip to content

Commit 4e1d01a

Browse files
clemblancooakleesfridzemaMatusBoa
authored
[1.x] Minor improvements + bump up to 1.x (#18)
* Minor improvements * Bump up to 1.x Co-authored-by: Andrew Lees <[email protected]> Co-authored-by: Robert Fridzema <[email protected]> Co-authored-by: Matúš Koterba <[email protected]>
1 parent 0b49229 commit 4e1d01a

File tree

10 files changed

+83
-46
lines changed

10 files changed

+83
-46
lines changed

.github/workflows/run-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
runs-on: ubuntu-16.04
7+
runs-on: ubuntu-latest
88
strategy:
99
fail-fast: true
1010
matrix:
11-
php: [ 7.3, 8.0 ]
11+
php: [ 7.4, 8.0 ]
1212
laravel: [ 7.*, 8.* ]
1313
include:
1414
- laravel: 7.*

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/.idea
2+
/.vscode
13
/vendor
24
composer.lock
35
/phpunit.xml

CHANGELOG.md

+36-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22

33
All notable changes to `laravel-mail-export` will be documented in this file.
44

5+
## 2.0.0 - 2022-08-04
6+
7+
- Laravel 9 Support **Breaking change** [#17](https://github.com/Pod-Point/laravel-mail-export/pull/17)
8+
- Moved from `swiftmailer/swiftmailer` to `symfony/mailer`
9+
- Thank you to [fridzema](https://github.com/fridzema) for contributing [#14](https://github.com/Pod-Point/laravel-mail-export/pull/14)
10+
11+
## 1.0.0 - 2022-08-04
12+
13+
- Minor improvements + bump up to `1.x` [#18](https://github.com/Pod-Point/laravel-mail-export/pull/18)
14+
- New contributor [MatusBoa](https://github.com/MatusBoa) see [#15](https://github.com/Pod-Point/laravel-mail-export/pull/15)
15+
16+
**Full Changelog**: https://github.com/Pod-Point/laravel-mail-export/compare/0.2.2...1.0.0
17+
18+
## 0.2.2 - 2021-09-14
19+
20+
- Bug: issue [#7](https://github.com/Pod-Point/laravel-mail-export/issues/7) Fix filesystems config file typo
21+
- Enhancement: Add `MAIL_EXPORT` environment variable support
22+
23+
## 0.2.1 - 2021-04-01
24+
25+
- Specify proper `.eml` mime type when saving the file into storage
26+
27+
## 0.2.0 - 2021-04-01
28+
29+
- Support for PHP 8.x, Laravel 7.x and 8.x
30+
31+
## 0.1.2 - 2021-09-14
32+
33+
- Bug: issue [#7](https://github.com/Pod-Point/laravel-mail-export/issues/7) Fix filesystems config file typo
34+
- Enhancement: Add `MAIL_EXPORT` environment variable support
35+
36+
## 0.1.1 - 2021-04-01
37+
38+
- Specify proper `.eml` mime type when saving the file into storage
39+
540
## 0.1.0 - 2021-03-29
641

7-
- first release supporting PHP 7.x & Laravel 5.x and 6.x
42+
- First release supporting PHP 7.x, Laravel 5.x and 6.x

README.md

+20-14
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@ This can be useful when wanting to store emails sent for archive purposes.
1313

1414
You can install the package via composer:
1515

16-
For Laravel 5.x and 6.x
16+
For Laravel 9.x
1717

1818
```bash
19-
composer require pod-point/laravel-mail-export:^0.1
19+
composer require pod-point/laravel-mail-export
2020
```
2121

2222
For Laravel 7.x and 8.x
2323

2424
```bash
25-
composer require pod-point/laravel-mail-export:^0.2
25+
composer require pod-point/laravel-mail-export:^1.0
26+
```
27+
28+
For Laravel 5.x and 6.x
29+
30+
```bash
31+
composer require pod-point/laravel-mail-export:^0.1
2632
```
2733

2834
### Publishing the config file
@@ -35,9 +41,9 @@ php artisan vendor:publish --provider="PodPoint\MailExport\MailExportServiceProv
3541

3642
You will be able to specify:
3743

38-
* `enabled`: wether this package is enabled or not.
44+
* `enabled`: whether this package is enabled or not. Once installed, it's enabled by default but the `MAIL_EXPORT` environment variable can be used to configure this.
3945
* `disk`: which disk to use by default. `null` will use the default disk from your application filesystem.
40-
* `path`: the default path you would like to export your mails within a storage disk.
46+
* `path`: the default path, within the configured disk, where mail will be exported.
4147

4248
See our [`config/mail-export.php`](config/mail-export.php) for more details.
4349

@@ -57,7 +63,7 @@ use PodPoint\MailExport\Contracts\ShouldExport;
5763
class OrderShipped extends Mailable implements ShouldExport
5864
{
5965
use Exportable;
60-
66+
6167
// ...
6268
}
6369
```
@@ -84,13 +90,13 @@ use PodPoint\MailExport\Contracts\ShouldExport;
8490
class OrderShipped extends Mailable implements ShouldExport
8591
{
8692
use Exportable;
87-
93+
8894
public $exportDisk = 'some_disk';
8995

9096
public $exportPath = 'some_path';
9197

9298
public $exportFilename = 'some_filename';
93-
99+
94100
// ...
95101
}
96102
```
@@ -109,9 +115,9 @@ use PodPoint\MailExport\Contracts\ShouldExport;
109115
class OrderShipped extends Mailable implements ShouldExport
110116
{
111117
use Exportable;
112-
118+
113119
// ...
114-
120+
115121
public function exportDisk(): string
116122
{
117123
return 'some_disk';
@@ -148,11 +154,11 @@ use Illuminate\Notifications\Notification;
148154
class OrderShipped extends Notification
149155
{
150156
// ...
151-
157+
152158
public function toMail($notifiable)
153159
{
154160
return (new Mailable($this->order))->to($notifiable->email);
155-
}
161+
}
156162
}
157163
```
158164

@@ -175,7 +181,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
175181
## Credits
176182

177183
- [themsaid](https://github.com/themsaid) and Spatie's [laravel-mail-preview](https://github.com/spatie/laravel-mail-preview) for some inspiration
178-
- [Laravel Package Development](https://laravelpackage.com) documentation by [John Braun](https://github.com/Jhnbrn90)
184+
- [Laravel Package Development](https://laravelpackage.com) documentation by [John Braun](https://github.com/Jhnbrn90)
179185
- [Pod Point](https://github.com/pod-point)
180186
- [All Contributors](https://github.com/pod-point/laravel-mail-export/graphs/contributors)
181187

@@ -189,4 +195,4 @@ The MIT License (MIT). Please see [License File](LICENCE.md) for more informatio
189195

190196
Travel shouldn't damage the earth 🌍
191197

192-
Made with ❤️ at [Pod Point](https://pod-point.com)
198+
Made with ❤️&nbsp;&nbsp;at [Pod Point](https://pod-point.com)

composer.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
],
1313
"require": {
1414
"php": "^7.2.5|^8.0",
15-
"nesbot/carbon": "^2.0",
16-
"illuminate/support": "~7.0|^8.0",
15+
"illuminate/filesystem": "~7.0|^8.0",
1716
"illuminate/mail": "~7.0|^8.0",
18-
"illuminate/filesystem": "~7.0|^8.0"
17+
"illuminate/support": "~7.0|^8.0",
18+
"nesbot/carbon": "^2.0"
1919
},
2020
"require-dev": {
2121
"orchestra/testbench": "^5.0|^6.0"
@@ -31,9 +31,6 @@
3131
}
3232
},
3333
"extra": {
34-
"branch-alias": {
35-
"dev-master": "0.2-dev"
36-
},
3734
"laravel": {
3835
"providers": [
3936
"PodPoint\\MailExport\\MailExportServiceProvider"

config/mail-export.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
|
1414
*/
1515

16-
'enabled' => true,
16+
'enabled' => env('MAIL_EXPORT', true),
1717

1818
/*
1919
|--------------------------------------------------------------------------

src/Events/MessageStored.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Foundation\Events\Dispatchable;
66
use PodPoint\MailExport\StorageOptions;
7+
use Swift_Message;
78

89
class MessageStored
910
{
@@ -20,18 +21,18 @@ class MessageStored
2021
* The filesystem storage options used to store the message including
2122
* the disk, the path and the filename with its extension.
2223
*
23-
* @var StorageOptions
24+
* @var \PodPoint\MailExport\StorageOptions
2425
*/
2526
public $storageOptions;
2627

2728
/**
2829
* Create a new event instance.
2930
*
30-
* @param \Swift_Message $message
31+
* @param Swift_Message $message
3132
* @param StorageOptions $storageOptions
3233
* @return void
3334
*/
34-
public function __construct($message, $storageOptions)
35+
public function __construct(Swift_Message $message, StorageOptions $storageOptions)
3536
{
3637
$this->message = $message;
3738
$this->storageOptions = $storageOptions;

src/Listeners/ExportMessage.php

+13-17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Mail\Events\MessageSent;
77
use PodPoint\MailExport\Events\MessageStored;
88
use PodPoint\MailExport\StorageOptions;
9+
use Swift_Message;
910

1011
class ExportMessage
1112
{
@@ -14,11 +15,6 @@ class ExportMessage
1415
*/
1516
protected $filesystem;
1617

17-
/**
18-
* @var \Swift_Message
19-
*/
20-
protected $message;
21-
2218
/**
2319
* Create a new listener instance.
2420
*
@@ -34,43 +30,43 @@ public function __construct(Factory $filesystem)
3430
*
3531
* @param MessageSent $event
3632
*/
37-
public function handle(MessageSent $event)
33+
public function handle(MessageSent $event): void
3834
{
39-
$this->message = $event->message;
40-
41-
if ($this->shouldStoreMessage()) {
42-
$this->storeMessage();
35+
if ($this->shouldStoreMessage($event->message)) {
36+
$this->storeMessage($event->message);
4337
}
4438
}
4539

4640
/**
47-
* Finds out if wether we should store the mail or not.
41+
* Finds out if whether we should store the mail or not.
4842
*
43+
* @param Swift_Message $message
4944
* @return bool
5045
*/
51-
protected function shouldStoreMessage(): bool
46+
protected function shouldStoreMessage(Swift_Message $message): bool
5247
{
53-
return property_exists($this->message, '_storageOptions')
48+
return property_exists($message, '_storageOptions')
5449
&& config('mail-export.enabled', false);
5550
}
5651

5752
/**
5853
* Actually stores the stringified version of the \Swift_Message including headers,
5954
* recipients, subject and body onto the filesystem disk.
6055
*
56+
* @param Swift_Message $message
6157
* @return void
6258
*/
63-
private function storeMessage()
59+
private function storeMessage(Swift_Message $message): void
6460
{
6561
/** @var StorageOptions $storageOptions */
66-
$storageOptions = $this->message->_storageOptions;
62+
$storageOptions = $message->_storageOptions;
6763

6864
$this->filesystem
6965
->disk($storageOptions->disk)
70-
->put($storageOptions->fullpath(), $this->message->toString(), [
66+
->put($storageOptions->fullpath(), $message->toString(), [
7167
'mimetype' => $storageOptions::MIME_TYPE,
7268
]);
7369

74-
event(new MessageStored($this->message, $storageOptions));
70+
event(new MessageStored($message, $storageOptions));
7571
}
7672
}

src/StorageOptions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(Swift_Message $message, array $properties = [])
6262
*/
6363
private function defaultDisk(): string
6464
{
65-
return config('mail-export.disk') ?: config('filesystem.default');
65+
return config('mail-export.disk') ?: config('filesystems.default');
6666
}
6767

6868
/**

tests/Feature/MailExportTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function it_will_export_mails_as_eml_files()
7373
/** @test */
7474
public function it_can_export_using_the_default_application_disk_if_none_is_given()
7575
{
76-
config()->set('filesystem.default', 'default_disk');
76+
config()->set('filesystems.default', 'default_disk');
7777
config()->set('mail-export.disk', null);
7878

7979
Storage::fake('local');

0 commit comments

Comments
 (0)