Compare commits

..

No commits in common. "main" and "1.0" have entirely different histories.
main ... 1.0

5 changed files with 15 additions and 53 deletions

21
LICENSE
View File

@ -1,21 +0,0 @@
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.4" "bluesquare/laravel-mail-templates": "^1.0"
}, },
"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": "MIT", "license": "proprietary",
"authors": [ "authors": [
{ {
"name": "Bluesquare", "name": "Bluesquare",
@ -18,7 +18,7 @@
"role": "Developers" "role": "Developers"
} }
], ],
"minimum-stability": "stable", "minimum-stability": "dev",
"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['email'] = $address; $this->sender['address'] = $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['email'] = $address; $this->replyTo['address'] = $address;
if (! empty($name)) if (! empty($name))
$this->replyTo['name'] = $name; $this->replyTo['name'] = $name;
@ -97,13 +97,11 @@ class MailTemplate implements \JsonSerializable
*/ */
public function recipients(array $recipients): MailTemplate public function recipients(array $recipients): MailTemplate
{ {
$this->recipients = []; if (!empty($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 = [
'email' => $recipient[0] 'address' => $recipient[0]
]; ];
if (!empty($recipient[1])) { if (!empty($recipient[1])) {
@ -130,7 +128,7 @@ class MailTemplate implements \JsonSerializable
public function addRecipient(string $address, array $informations = []): MailTemplate public function addRecipient(string $address, array $informations = []): MailTemplate
{ {
$data = [ $data = [
'email' => $address 'address' => $address
]; ];
if (!empty($informations)) { if (!empty($informations)) {
@ -162,7 +160,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['url'] ?? $attachment['path'] ?? $attachment['file'], $attachment['filename'] ?? null); $this->addAttachment($attachment['path'] ?? $attachment['file'], $attachment['filename'] ?? null);
} }
return $this; return $this;

View File

@ -53,6 +53,10 @@ 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([
@ -61,31 +65,12 @@ 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']));
} }