config = $config; $api_config = \SendinBlue\Client\Configuration::getDefaultConfiguration() ->setApiKey('api-key', $config['api_key']); if (! empty($config['api_url'])) $api_config->setHost($config['api_url']); $this->api = new TransactionalEmailsApi( new \GuzzleHttp\Client(), $api_config ); } public function send(MailTemplate $template, $notifiable = null) { $data = $template->toArray(); $model = new SendSmtpEmail(); $template = $data['templateId']; if (isset($config['map']['sendinblue']) && $config['map']['sendinblue'][$template]) { $template = $config['map']['sendinblue'][$template]; } $model->setTemplateId($template); $model->setParams($data['parameters']); $model->setSender(new SendSmtpEmailSender($data['sender'])); if ($data['replyTo']) $model->setReplyTo(new SendSmtpEmailReplyTo($data['replyTo'])); $model->setTo(array_map(function ($to) { return new SendSmtpEmailTo($to); }, $data['recipients'])); if (! empty($config['redirect'])) $model->setTo([ new SendSmtpEmailTo([ 'email' => $config['redirect'] ]) ]); $model->setAttachment(array_map(function ($item) { $attachment = new SendSmtpEmailAttachment(); $attachment->setName($item['filename']); $attachment->setContent(file_get_contents($item['path'])); return $attachment; }, $data['attachments'])); $this->api->sendTransacEmail($model); } }