I want to test email delivery in Behat tests in Symfony 5. Apparently, there is a MailerAssertionsTrait
in the PHPUnit package for Symfony which uses the MessageLoggerListener
to check the sent emails. Following this tutorial https://swag.industries/test-emails-with-symfony/, I adapted that trait for my Behat context.
Unfortunately the service mailer.message_logger_listener
does not seem to be available in the Symfony container. No matter if I set the MAILER_DSN
to null://null
or to an actually working transport.
I saw that this listener is being registered in the file vendor/symfony/framework-bundle/Resources/config/mailer_debug.php
, which leads me to believe that I have to enable debug mode for the symfony/mailer
package in some way. But I did not yet find out how exactly that is done.
How do I enable the MessageLoggerListener
for the symfony/mailer
package in my test environment?