I use symfonymailer the way described in Sending Emails with Mailer/Debugging emails
The SentMessage object returned by the send() method of the TransportInterface provides access to the original message (getOriginalMessage()) and to some debug information (getDebug()) such as the HTTP calls done by the HTTP transports, which is useful to debug errors.
The way i use it currently:
public function __construct(private MailerInterface $mailer)
try
{
$this->mailer->send($message);
}
catch (TransportExceptionInterface $e)
{
echo $e->getDebug();
}
Since $this->mailer->send($message)
is an MailerInterface
it returns nothing. By having SentMessage object all the information about the sent mail would be present.
How can I retrieve the SentMessage object when sending the mail?