Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
Maxime | a748be45ae | |
Maxime | e75c29f6ac | |
Maxime | b2aebb75b0 | |
Maxime | 1aaccd43cb | |
Maxime | a187e3fff0 | |
Maxime | 463de25f28 | |
Maxime | 451789b71a | |
Maxime | b5e447ed15 | |
Maxime | e55b5192fd | |
Maxime | 026d944c98 |
|
@ -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.
|
|
@ -8,7 +8,7 @@ Ajouter à `composer.json` :
|
||||||
|
|
||||||
```
|
```
|
||||||
"require": {
|
"require": {
|
||||||
"bluesquare/laravel-mail-templates": "^1.0"
|
"bluesquare/laravel-mail-templates": "^1.4"
|
||||||
},
|
},
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -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/"
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
$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 = [
|
||||||
'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;
|
||||||
|
|
|
@ -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']));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue