Compare commits

..

10 Commits
1.0 ... 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
Maxime e55b5192fd Update 'src/MailTemplate.php' 2023-01-14 19:00:26 +01:00
Maxime 026d944c98 v1.1 2023-01-14 18:59:38 +01:00
5 changed files with 53 additions and 15 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": { "require": {
"bluesquare/laravel-mail-templates": "^1.0" "bluesquare/laravel-mail-templates": "^1.4"
}, },
"repositories": [ "repositories": [
{ {

View File

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

View File

@ -68,7 +68,7 @@ class MailTemplate implements \JsonSerializable
*/ */
public function sender(string $address, string $name = null): MailTemplate public function sender(string $address, string $name = null): MailTemplate
{ {
$this->sender['address'] = $address; $this->sender['email'] = $address;
if (! empty($name)) if (! empty($name))
$this->sender['name'] = $name; $this->sender['name'] = $name;
@ -83,7 +83,7 @@ class MailTemplate implements \JsonSerializable
*/ */
public function replyTo(string $address, string $name = null): MailTemplate public function replyTo(string $address, string $name = null): MailTemplate
{ {
$this->replyTo['address'] = $address; $this->replyTo['email'] = $address;
if (! empty($name)) if (! empty($name))
$this->replyTo['name'] = $name; $this->replyTo['name'] = $name;
@ -97,11 +97,13 @@ class MailTemplate implements \JsonSerializable
*/ */
public function recipients(array $recipients): MailTemplate public function recipients(array $recipients): MailTemplate
{ {
if (!empty($recipients)) { $this->recipients = [];
if (! empty($recipients)) {
foreach ($recipients as $recipient) { foreach ($recipients as $recipient) {
if (!empty($recipient[0]) && is_string($recipient[0])) { if (!empty($recipient[0]) && is_string($recipient[0])) {
$data = [ $data = [
'address' => $recipient[0] 'email' => $recipient[0]
]; ];
if (!empty($recipient[1])) { if (!empty($recipient[1])) {
@ -128,7 +130,7 @@ class MailTemplate implements \JsonSerializable
public function addRecipient(string $address, array $informations = []): MailTemplate public function addRecipient(string $address, array $informations = []): MailTemplate
{ {
$data = [ $data = [
'address' => $address 'email' => $address
]; ];
if (!empty($informations)) { if (!empty($informations)) {
@ -160,7 +162,7 @@ class MailTemplate implements \JsonSerializable
public function attachments(array $attachments): MailTemplate public function attachments(array $attachments): MailTemplate
{ {
foreach ($attachments as $attachment) { 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; return $this;

View File

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