diff --git a/src/Core/Listeners/BeforeSendingMailListener.php b/src/Core/Listeners/BeforeSendingMailListener.php index 26a1867..d310bc3 100644 --- a/src/Core/Listeners/BeforeSendingMailListener.php +++ b/src/Core/Listeners/BeforeSendingMailListener.php @@ -49,7 +49,6 @@ private function storeAttachments(array $attachments, BetterEmail $mail): void } $disk = config('filament-better-mails.mails.logging.attachments.disk', 'local'); - $root = config('filament-better-mails.mails.logging.attachments.root', 'mails/attachments'); foreach ($attachments as $part) { $filename = $part->getFilename() ?? 'attachment'; @@ -64,10 +63,7 @@ private function storeAttachments(array $attachments, BetterEmail $mail): void 'size' => strlen($content), ]); - Storage::disk($disk)->put( - $root.'/'.$attachment->getKey().'/'.$filename, - $content, - ); + Storage::disk($attachment->disk)->put($attachment->storage_path, $content); } } } diff --git a/src/Core/Models/BetterEmailAttachment.php b/src/Core/Models/BetterEmailAttachment.php index 4ad2648..ebdaca0 100644 --- a/src/Core/Models/BetterEmailAttachment.php +++ b/src/Core/Models/BetterEmailAttachment.php @@ -56,7 +56,9 @@ public function mail(): BelongsTo public function getStoragePathAttribute(): string { - return rtrim(config('filament-better-mails.logging.attachments.root'), '/').'/'.$this->getKey().'/'.$this->filename; + $root = config('filament-better-mails.mails.logging.attachments.root', 'mails/attachments'); + + return rtrim($root, '/').'/'.$this->getKey().'/'.$this->filename; } public function getFileDataAttribute(): string diff --git a/tests/Feature/Core/Models/BetterEmailAttachmentTest.php b/tests/Feature/Core/Models/BetterEmailAttachmentTest.php new file mode 100644 index 0000000..fa2a0d0 --- /dev/null +++ b/tests/Feature/Core/Models/BetterEmailAttachmentTest.php @@ -0,0 +1,74 @@ +subject('Test Subject') + ->from('from@example.com') + ->to('richard@3points.com') + ->html('