mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Service\Mailer;
|
|
|
|
use Psr\Log\LoggerInterface;
|
|
use Symfony\Component\Mailer\Envelope;
|
|
use Symfony\Component\Mailer\MailerInterface;
|
|
use Symfony\Component\Mime\Address;
|
|
use Symfony\Component\Mime\Email;
|
|
use Symfony\Component\Mime\RawMessage;
|
|
|
|
class ChillMailer implements MailerInterface
|
|
{
|
|
private string $prefix = '[Chill] ';
|
|
|
|
public function __construct(private readonly MailerInterface $initial, private readonly LoggerInterface $chillLogger) {}
|
|
|
|
public function send(RawMessage $message, ?Envelope $envelope = null): void
|
|
{
|
|
if ($message instanceof Email) {
|
|
$message->subject($this->prefix . $message->getSubject());
|
|
}
|
|
|
|
$this->chillLogger->info('chill email sent', [
|
|
'to' => array_map(static fn (Address $address) => $address->getAddress(), $message->getTo()),
|
|
'subject' => $message->getSubject(),
|
|
]);
|
|
|
|
$this->initial->send($message, $envelope);
|
|
}
|
|
}
|