Search code examples
symfonymailgunmonolog

How to Configure Monolog to Email Errors With symfony/mailer


In my Symfony 4.3 project I use symfony/mailer with symfony/mailgun-mailer to send emails via mailgun. I want to receive emails about errors, so I use monolog, but in monolog documentation I can't find how to send emails via symfony/mailer. Can anyone help me to configure monolog to receive emails about errors via mailgun and if it is possible to add specific tag to that emails.


Solution

  • According to the (4.3 and 5.0) monolog docs it's currently not possible to use the new symfony mailer for sending error emails: https://symfony.com/doc/4.3/logging/monolog_email.html

    This feature is not compatible yet with the new Symfony mailer, so it requires using SwiftMailer.

    But, there is an open pull request for monolog bridge that would fix it, maybe its worth watching https://github.com/symfony/symfony/pull/33456