Skip to content

Document usage of Symfony Mailer for error email #14360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .doctor-rst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,4 @@ whitelist:
- '.. versionadded:: 0.2' # MercureBundle
- 'provides a ``loginUser()`` method to simulate logging in in your functional'
- '.. code-block:: twig'
- '.. versionadded:: 3.6' # MonologBundle
49 changes: 24 additions & 25 deletions logging/monolog_email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
How to Configure Monolog to Email Errors
========================================

.. caution::
.. versionadded:: 3.6

This feature is not compatible yet with the new :doc:`Symfony mailer </mailer>`,
so it requires using SwiftMailer.
Support for emailing errors using :doc:`Symfony mailer </mailer>` was added in MonologBundle 3.6.

`Monolog`_ can be configured to send an email when an error occurs within an
application. The configuration for this requires a few nested handlers
Expand All @@ -33,9 +32,9 @@ it is broken down.
handler: deduplicated
deduplicated:
type: deduplication
handler: swift
swift:
type: swift_mailer
handler: symfony_mailer
symfony_mailer:
type: symfony_mailer
from_email: '[email protected]'
to_email: '[email protected]'
# or list of recipients
Expand Down Expand Up @@ -73,11 +72,11 @@ it is broken down.
<monolog:handler
name="deduplicated"
type="deduplication"
handler="swift"
handler="symfony_mailer"
/>
<monolog:handler
name="swift"
type="swift_mailer"
name="symfony_mailer"
type="symfony_mailer"
from-email="[email protected]"
subject="An Error Occurred! %%message%%"
level="debug"
Expand Down Expand Up @@ -114,10 +113,10 @@ it is broken down.
],
'deduplicated' => [
'type' => 'deduplication',
'handler' => 'swift',
'handler' => 'symfony_mailer',
],
'swift' => [
'type' => 'swift_mailer',
'symfony_mailer' => [
'type' => 'symfony_mailer',
'from_email' => '[email protected]',
'to_email' => '[email protected]',
// or a list of recipients
Expand Down Expand Up @@ -162,7 +161,7 @@ You can adjust the time period using the ``time`` option:
type: deduplication
# the time in seconds during which duplicate entries are discarded (default: 60)
time: 10
handler: swift
handler: symfony_mailer

.. code-block:: xml

Expand All @@ -172,7 +171,7 @@ You can adjust the time period using the ``time`` option:
<monolog:handler name="deduplicated"
type="deduplication"
time="10"
handler="swift"/>
handler="symfony_mailer"/>

.. code-block:: php

Expand All @@ -184,12 +183,12 @@ You can adjust the time period using the ``time`` option:
'type' => 'deduplication',
// the time in seconds during which duplicate entries are discarded (default: 60)
'time' => 10,
'handler' => 'swift',
'handler' => 'symfony_mailer',
],
],
]);

The messages are then passed to the ``swift`` handler. This is the handler that
The messages are then passed to the ``symfony_mailer`` handler. This is the handler that
actually deals with emailing you the error. The settings for this are
straightforward, the to and from addresses, the formatter, the content type
and the subject.
Expand Down Expand Up @@ -217,9 +216,9 @@ get logged on the server as well as the emails being sent:
level: debug
deduplicated:
type: deduplication
handler: swift
swift:
type: swift_mailer
handler: symfony_mailer
symfony_mailer:
type: symfony_mailer
from_email: '[email protected]'
to_email: '[email protected]'
subject: 'An Error Occurred! %%message%%'
Expand Down Expand Up @@ -259,11 +258,11 @@ get logged on the server as well as the emails being sent:
<monolog:handler
name="deduplicated"
type="deduplication"
handler="swift"
handler="symfony_mailer"
/>
<monolog:handler
name="swift"
type="swift_mailer"
name="symfony_mailer"
type="symfony_mailer"
from-email="[email protected]"
subject="An Error Occurred! %%message%%"
level="debug"
Expand Down Expand Up @@ -303,10 +302,10 @@ get logged on the server as well as the emails being sent:
],
'deduplicated' => [
'type' => 'deduplication',
'handler' => 'swift',
'handler' => 'symfony_mailer',
],
'swift' => [
'type' => 'swift_mailer',
'symfony_mailer' => [
'type' => 'symfony_mailer',
'from_email' => '[email protected]',
'to_email' => '[email protected]',
// or a list of recipients
Expand Down