Compare commits

...

8 Commits
1.1 ... main

Author SHA1 Message Date
Maxime a748be45ae Update 'composer.json' 2023-06-20 10:19:53 +02:00
Maxime e75c29f6ac Add 'LICENSE' 2023-06-19 17:33:50 +02:00
Maxime b2aebb75b0 Update 'README.md' 2023-02-28 16:36:25 +01:00
Maxime 1aaccd43cb fix: flush recipients 2023-02-03 11:34:22 +01:00
Maxime a187e3fff0 Update 'src/Providers/SendinblueProvider.php' 2023-01-16 01:09:35 +01:00
Maxime 463de25f28 Update 'README.md' 2023-01-14 19:31:23 +01:00
Maxime 451789b71a Update 'src/Providers/SendinblueProvider.php' 2023-01-14 19:12:34 +01:00
Maxime b5e447ed15 Update 'src/MailTemplate.php' 2023-01-14 19:09:54 +01:00
5 changed files with 49 additions and 11 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 BlUESQUARE COMPUTING
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -8,7 +8,7 @@ Ajouter à `composer.json` :
```
"require": {
"bluesquare/laravel-mail-templates": "^1.1"
"bluesquare/laravel-mail-templates": "^1.4"
},
"repositories": [
{

View File

@ -9,7 +9,7 @@
"email"
],
"homepage": "https://git.bluesquare.io/bluesquare/laravel-mail-templates",
"license": "proprietary",
"license": "MIT",
"authors": [
{
"name": "Bluesquare",
@ -18,7 +18,7 @@
"role": "Developers"
}
],
"minimum-stability": "dev",
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Bluesquare\\MailTemplates\\": "src/"

View File

@ -97,7 +97,9 @@ class MailTemplate implements \JsonSerializable
*/
public function recipients(array $recipients): MailTemplate
{
if (!empty($recipients)) {
$this->recipients = [];
if (! empty($recipients)) {
foreach ($recipients as $recipient) {
if (!empty($recipient[0]) && is_string($recipient[0])) {
$data = [
@ -160,7 +162,7 @@ class MailTemplate implements \JsonSerializable
public function attachments(array $attachments): MailTemplate
{
foreach ($attachments as $attachment) {
$this->addAttachment($attachment['path'] ?? $attachment['file'], $attachment['filename'] ?? null);
$this->addAttachment($attachment['url'] ?? $attachment['path'] ?? $attachment['file'], $attachment['filename'] ?? null);
}
return $this;

View File

@ -53,10 +53,6 @@ class SendinblueProvider implements TemplateMailProvider
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'])) {
Log::info("Redirecting SIB mail to: " . $config['redirect']);
$model->setTo([
@ -65,12 +61,31 @@ class SendinblueProvider implements TemplateMailProvider
])
]);
}
elseif (count($data['recipients']) == 0 && ! empty($notifiable?->email)) {
$model->setTo([
new SendSmtpEmailTo([
'email' => $notifiable->email
])
]);
}
else {
$model->setTo(array_map(function ($to) {
return new SendSmtpEmailTo($to);
}, $data['recipients']));
}
if (! empty($data['attachments'])) {
$model->setAttachment(array_map(function ($item) {
$attachment = new SendSmtpEmailAttachment();
$attachment->setName($item['filename']);
$attachment->setContent(file_get_contents($item['path']));
if (isset($item['filename']))
$attachment->setName($item['filename']);
if (strpos($item['path'], 'http') === 0)
$attachment->setUrl($item['path']);
else
$attachment->setContent(file_get_contents($item['path']));
return $attachment;
}, $data['attachments']));
}