[GH-ISSUE #1621] Implement a symfony/mailer handler #689

Closed
opened 2026-03-04 02:17:02 +03:00 by kerem · 7 comments
Owner

Originally created by @MaximilianKresse on GitHub (Dec 14, 2021).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1621

As swiftmailer is abandoned many of us are "forced" to search for an alternative. The recommended alternative is symfony/mailer.

I'm not using the Symfony Framework but only the symfony/mailer. I know there is an implementation inside the monolog-bridge. But the monolog-bridge has some dependencies which I absolutely not need e.g. symfony/http-kernel. So i don't want to require the monolog-bridge as I'm only missing the monolog handler.

Is there a chance we could get an implementation directly inside the monolog package like with the swiftmailer handler?

Originally created by @MaximilianKresse on GitHub (Dec 14, 2021). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1621 As swiftmailer is abandoned many of us are "forced" to search for an alternative. The recommended alternative is [symfony/mailer](https://github.com/symfony/mailer). I'm not using the Symfony Framework but only the ```symfony/mailer```. I know there is an implementation inside the [monolog-bridge](https://github.com/symfony/monolog-bridge). But the ```monolog-bridge``` has some dependencies which I absolutely not need e.g. ```symfony/http-kernel```. So i don't want to require the ```monolog-bridge``` as I'm only missing the monolog handler. Is there a chance we could get an implementation directly inside the monolog package like with the swiftmailer handler?
kerem 2026-03-04 02:17:02 +03:00
  • closed this issue
  • added the
    Feature
    label
Author
Owner

@stof commented on GitHub (Dec 14, 2021):

AFAIK the monolog package itself has stopped accepting handlers that rely on additional dependencies, as it makes it very hard to manage dependencies (the monolog package cannot require those dependencies, as it would annoy all projects not using that handler). That's also why the wiki has a list of third-party packages related to monolog.

<!-- gh-comment-id:993766981 --> @stof commented on GitHub (Dec 14, 2021): AFAIK the monolog package itself has stopped accepting handlers that rely on additional dependencies, as it makes it very hard to manage dependencies (the monolog package cannot require those dependencies, as it would annoy all projects not using that handler). That's also why the wiki has a [list of third-party packages](https://github.com/Seldaek/monolog/wiki/Third-Party-Packages) related to monolog.
Author
Owner

@MaximilianKresse commented on GitHub (Dec 14, 2021):

Ok thank you for your answer. That makes sense! I'll take a look at an alternative approach.

<!-- gh-comment-id:993845574 --> @MaximilianKresse commented on GitHub (Dec 14, 2021): Ok thank you for your answer. That makes sense! I'll take a look at an alternative approach.
Author
Owner

@Seldaek commented on GitHub (Mar 6, 2022):

Yeah for this I think I may want to make an exception though as email support is kinda core IMO and just relying on mail() makes for a poor UX.

SwiftMailerHandler needs to be deprecated, and MandrillHandler also relies on SwiftMailer being present to build a message so this would need to be updated too.

<!-- gh-comment-id:1059955724 --> @Seldaek commented on GitHub (Mar 6, 2022): Yeah for this I think I may want to make an exception though as email support is kinda core IMO and just relying on mail() makes for a poor UX. SwiftMailerHandler needs to be deprecated, and MandrillHandler also relies on SwiftMailer being present to build a message so this would need to be updated too.
Author
Owner

@Seldaek commented on GitHub (Mar 6, 2022):

If someone wants to help with this that'd be great btw.

<!-- gh-comment-id:1059955767 --> @Seldaek commented on GitHub (Mar 6, 2022): If someone wants to help with this that'd be great btw.
Author
Owner

@driesvints commented on GitHub (Mar 14, 2022):

I'll answer @dmitry-ivanov's question here. It's true that we don't use Symfony's Mailer directly, just the transports. It's because we already have our own Mailer class with its send method. Changing it would be a really big breaking change to our users.

I'm not too familiar with Monolog's handlers or inner workings so I'm not sure I can answer what's needed to make this work on the Laravel side of things.

<!-- gh-comment-id:1066504511 --> @driesvints commented on GitHub (Mar 14, 2022): I'll answer @dmitry-ivanov's [question](https://github.com/Seldaek/monolog/issues/1638#issuecomment-1065085268) here. It's true that we don't use Symfony's Mailer directly, just the transports. It's because we already have our own Mailer class with its `send` method. Changing it would be a really big breaking change to our users. I'm not too familiar with Monolog's handlers or inner workings so I'm not sure I can answer what's needed to make this work on the Laravel side of things.
Author
Owner

@raziel057 commented on GitHub (Mar 16, 2022):

Please note that with the current implementation of monolog-bridge there is an issue when using SmtpTransport related to the fact that Symfony Mailer use monolog to log in the stop method https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php

https://github.com/symfony/monolog-bundle/issues/405

<!-- gh-comment-id:1069047056 --> @raziel057 commented on GitHub (Mar 16, 2022): Please note that with the current implementation of monolog-bridge there is an issue when using SmtpTransport related to the fact that Symfony Mailer use monolog to log in the ``stop`` method https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php https://github.com/symfony/monolog-bundle/issues/405
Author
Owner

@Seldaek commented on GitHub (May 3, 2022):

See https://github.com/Seldaek/monolog/pull/1663

<!-- gh-comment-id:1116499453 --> @Seldaek commented on GitHub (May 3, 2022): See https://github.com/Seldaek/monolog/pull/1663
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#689
No description provided.