Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ SENT_EMAILS_PER_PAGE=10
SENT_EMAILS_STORE_EMAILS=true
SENT_EMAILS_NO_EMAILS_MESSAGE='No emails have been sent'
SENT_EMAILS_COMPRESS_BODY=true
SENT_EMAILS_STORAGE_DISK='local'
```

## Views
Expand Down
3 changes: 3 additions & 0 deletions config/sentemails.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
// body emails are stored as compressed strings to save db disk
/* Do not change after first mail is stored */
'compressBody' => env('SENT_EMAILS_COMPRESS_BODY', false),

// Set custom storage disk
'storageDisk' => env('SENT_EMAILS_STORAGE_DISK', 'local'),
];
5 changes: 4 additions & 1 deletion src/Controllers/SentEmailsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Illuminate\Support\Facades\Storage;

class SentEmailsController
{
Expand Down Expand Up @@ -37,6 +38,8 @@ public function downloadAttachment(string $id): BinaryFileResponse
{
$attachment = SentEmailAttachment::findOrFail($id);

return response()->download(storage_path('app/'.$attachment->path), $attachment->filename);
$path = Storage::disk(config('sentemails.storageDisk', 'local'))->path($attachment->path);

return response()->download($path, $attachment->filename);
}
}
2 changes: 1 addition & 1 deletion src/Listeners/EmailLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function handle(MessageSending $event): void
foreach ($message->getAttachments() as $attachment) {

$path = 'sent-emails/'.now().'-'.$attachment->getFilename();
Storage::disk('local')->put($path, $attachment->getBody());
Storage::disk(config('sentemails.storageDisk', 'local'))->put($path, $attachment->getBody());

SentEmailAttachment::create([
'sent_email_id' => $email->id,
Expand Down
Loading