diff --git a/src/BluescaleMailApi.php b/src/BluescaleMailApi.php index 3a3cfbd..e816cca 100644 --- a/src/BluescaleMailApi.php +++ b/src/BluescaleMailApi.php @@ -5,6 +5,8 @@ namespace Bluescale\Mail; use Bluescale\Mail\BluescaleMailTemplate; use GuzzleHttp\Client; use Psr\Http\Message\StreamInterface; +use Symfony\Component\HttpFoundation\File\UploadedFile; + class BluescaleMailApi { @@ -37,6 +39,7 @@ class BluescaleMailApi $notifiable_recipient = false; $notifiable_email = $notifiable->email; $recipients = $template->recipients; + $attachments = $template->attachments; if (count($recipients) > 0) foreach ($recipients as $recipient) @@ -48,6 +51,16 @@ class BluescaleMailApi $template->recipients[] = [ 'address' => $notifiable->email ]; + + if (count($attachments) > 0) { + $formatted_attachmments = []; + foreach ($attachments as $attachment) { + $file = new UploadedFile($attachment->path, $attachment->fileName, 'application/octet-stream', null, null, false); + $formatted_attachmments[] = $file; + } + + $template->attachments($formatted_attachmments); + } } try {