fix sib attachment

This commit is contained in:
Maxime 2022-12-05 12:49:34 +01:00
parent 08d230befd
commit 725d6d7573
1 changed files with 12 additions and 7 deletions

View File

@ -3,6 +3,7 @@
namespace Bluesquare\MailTemplates\Providers; namespace Bluesquare\MailTemplates\Providers;
use Bluesquare\MailTemplates\MailTemplate; use Bluesquare\MailTemplates\MailTemplate;
use Illuminate\Support\Facades\Log;
use SendinBlue\Client\Api\TransactionalEmailsApi; use SendinBlue\Client\Api\TransactionalEmailsApi;
use SendinBlue\Client\Model\SendSmtpEmail; use SendinBlue\Client\Model\SendSmtpEmail;
use SendinBlue\Client\Model\SendSmtpEmailAttachment; use SendinBlue\Client\Model\SendSmtpEmailAttachment;
@ -56,19 +57,23 @@ class SendinblueProvider implements TemplateMailProvider
return new SendSmtpEmailTo($to); return new SendSmtpEmailTo($to);
}, $data['recipients'])); }, $data['recipients']));
if (! empty($config['redirect'])) if (! empty($config['redirect'])) {
Log::info("Redirecting SIB mail to: " . $config['redirect']);
$model->setTo([ $model->setTo([
new SendSmtpEmailTo([ new SendSmtpEmailTo([
'email' => $config['redirect'] 'email' => $config['redirect']
]) ])
]); ]);
}
if (! empty($data['attachments'])) {
$model->setAttachment(array_map(function ($item) { $model->setAttachment(array_map(function ($item) {
$attachment = new SendSmtpEmailAttachment(); $attachment = new SendSmtpEmailAttachment();
$attachment->setName($item['filename']); $attachment->setName($item['filename']);
$attachment->setContent(file_get_contents($item['path'])); $attachment->setContent(file_get_contents($item['path']));
return $attachment; return $attachment;
}, $data['attachments'])); }, $data['attachments']));
}
$this->api->sendTransacEmail($model); $this->api->sendTransacEmail($model);
} }