title: Symfony Mailer, MessageEvent Never fired - 5.4 LTS
body: <p>i'm trying to write a log when my app in symfony 5.4 send an email.
  But it seems that the MessageEvent is never fired.</p>
  <p>In the console the EventListener seem to be registered correctly:</p>
  <pre><code># bin/console debug:event-dispatcher
  </code></pre>
  <h1>Registered Listeners Grouped by Event</h1>
  <h2>&quot;Symfony\Component\Mailer\Event\MessageEvent&quot; event</h2>
  <hr />
  <p>Order   Callable                                                                    Priority</p>
  <hr />
  <p>#1      App\EventSubscriber\MailerLoggerSubscriber::onMessage()                     0<br />
  #2      Symfony\Component\Mailer\EventListener\MessageListener::onMessage()         0<br />
  #3      Symfony\Component\Mailer\EventListener\EnvelopeListener::onMessage()        -255<br />
  #4      Symfony\Component\Mailer\EventListener\MessageLoggerListener::onMessage()   -255</p>
  <hr />
  <p>Here my EventListener:</p>
  <pre><code>&lt;?php
  
  namespace App\EventSubscriber;
  
  use App\Entity\MailLog;
  use App\Repository\MailLogRepository;
  use Doctrine\ORM\EntityManagerInterface;
  use Psr\Log\LoggerInterface;
  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  use Symfony\Component\Mailer\Event\MessageEvent;
  
  class MailerLoggerSubscriber implements EventSubscriberInterface
  {
     protected MailLogRepository $mailerRepository;
     protected EntityManagerInterface $entityManager;
     protected LoggerInterface $logger;
  
     public function __construct(MailLogRepository 
     $mailerRepository,EntityManagerInterface $entityManager, LoggerInterface $logger)
     {
         $this-&gt;mailerRepository = $mailerRepository;
         $this-&gt;entityManager = $entityManager;
         $this-&gt;logger = $logger;
     }
  
  public static function getSubscribedEvents()
  {
      return [
          MessageEvent::class =&gt; ['onMessage', -255],
      ];
  }
  
  
  public function onMessage(MessageEvent $event): void
  {
  
      $message = $event-&gt;getMessage();
  
      // do nothing with a spooled messages, there comes a second send event
      /*if ($this-&gt;getReadableResult($event) === 'spooled') {
          return false;
      }*/
      $envelope = $event-&gt;getEnvelope();
      $fromAddresses = [];
      foreach ($envelope-&gt;getSender() as $add) {
          $fromAddresses[] = $add;
      }
  
      $toAddresses = [];
      foreach ($envelope-&gt;getRecipients() as $add) {
          $toAddresses[] = $add;
      }
  
      $mailLog = new MailLog();
      $mailLog-&gt;setSentAt(new \DateTime());
      $mailLog-&gt;setFrom(array_keys($fromAddresses));
      $mailLog-&gt;setTo(array_keys($toAddresses));
      $mailLog-&gt;setSubject('subject');
      $mailLog-&gt;setMessage($event-&gt;getMessage()-&gt;toString());
      $mailLog-&gt;setResult('success');
  
      $this-&gt;entityManager-&gt;persist($mailLog);
      $this-&gt;entityManager-&gt;flush();
  }
  </code></pre>
  <p>}</p>