protected function flushEmail(SpoolEmailInterface $email): void
    {
        $email->setSentAt(new \DateTime());
        $this->om->persist($email);
        $this->om->flush();

        if (SpoolEmailStatus::STATUS_SUCCESS === $email->getStatus()) {
            $this->om->remove($email);
            $this->om->flush();
        }

        $this->om->detach($email);
    }