From 033ee647247d528a240ac7209f50366cae6307e8 Mon Sep 17 00:00:00 2001 From: Loann Meignant Date: Mon, 8 Jun 2020 12:00:43 +0200 Subject: [PATCH] Modifying API --- src/BluescaleMailApi.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 {