for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Silverback API Components Bundle Project
*
* (c) Daniel West <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Silverback\ApiComponentsBundle\EventListener\Mailer;
use Symfony\Component\Mailer\Event\MessageEvent;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
/**
* @author Daniel West <[email protected]>
class MessageEventListener
{
private string $fromEmailAddress;
public function __construct(string $fromEmailAddress)
$this->fromEmailAddress = $fromEmailAddress;
}
public function __invoke(MessageEvent $messageEvent): void
$message = $messageEvent->getMessage();
if (!$message instanceof Email) {
return;
$message->from(Address::fromString($this->fromEmailAddress));