Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ea7ad3

Browse files
committed
minor#20186 [Mailer] Mention theSentMessageEvent andFailedMessageEvent (wkania)
This PR was merged into the 6.4 branch.Discussion----------[Mailer] Mention the `SentMessageEvent` and `FailedMessageEvent`Thesymfony/symfony#47080 PR was created to solve the problem of [debugging](symfony/symfony#37570) and to get [information](symfony/symfony#42108) about email after it was sent.The section about [debugging](https://symfony.com/doc/current/mailer.html#debugging-emails) does not mention those events. Added some links for better navigation.For example what debug returns:```< 220 ESMTP SYMFONY.COM> EHLO [127.0.0.1]< 250-smtp.symfony.com< 250-PIPELINING< 250-SIZE 157286400< 250-AUTH PLAIN LOGIN PLAIN LOGIN PLAIN LOGIN< 250-AUTH=PLAIN LOGIN PLAIN LOGIN PLAIN LOGIN< 250-ENHANCEDSTATUSCODES< 250-8BITMIME< 250 SMTPUTF8> AUTH LOGIN< 334 VXNlcm5hbWU6> ZXhhbXBsZUBzeW1mb255LmNvbQ==< 334 UGFzc3dvcmQ6> U3ltcGhvbnkg.aXMgQXdlc29tZQ==< 235 2.7.0 Authentication successful> MAIL FROM:<example@symfony.com>< 250 2.1.0 Ok> RCPT TO:<dummy@symfony.com>< 250 2.1.5 Ok> DATA< 354 End data with <CR><LF>.<CR><LF>> .< 250 OK. ID: a20fb6ebbc54d22b```P.S.I see that the checks now can find repeated words:```mailer.rst ✘ 1765: The word "the" is used more times in a row. -> ``FailedMessageEvent`` allows acting on the the initial message in case of a failure and some```Commits-------8e3c1db [Mailer] Mention the SentMessageEvent and FailedMessageEvent in the debug section
2 parents21dffc6 +8e3c1db commit0ea7ad3

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

‎mailer.rst‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ Catch that exception to recover from the error or to display some message::
802802
// error message or try to resend the message
803803
}
804804

805+
.. _mailer-debugging-emails:
806+
805807
Debugging Emails
806808
----------------
807809

@@ -810,6 +812,9 @@ The :class:`Symfony\\Component\\Mailer\\SentMessage` object returned by the
810812
provides access to the original message (``getOriginalMessage()``) and to some
811813
debug information (``getDebug()``) such as the HTTP calls done by the HTTP
812814
transports, which is useful to debug errors.
815+
Access to:class:`Symfony\\Component\\Mailer\\SentMessage` can also be obtained by listening
816+
to the:ref:`SentMessageEvent<mailer-sent-message-event>`, and to ``getDebug()`` by listening
817+
to the:ref:`FailedMessageEvent<mailer-failed-message-event>`."
813818

814819
..note::
815820

@@ -1712,6 +1717,8 @@ and their priorities:
17121717
17131718
$ php bin/console debug:event-dispatcher "Symfony\Component\Mailer\Event\MessageEvent"
17141719
1720+
.. _mailer-sent-message-event:
1721+
17151722
SentMessageEvent
17161723
~~~~~~~~~~~~~~~~
17171724

@@ -1722,16 +1729,17 @@ SentMessageEvent
17221729
The ``SentMessageEvent`` event was introduced in Symfony 6.2.
17231730

17241731
``SentMessageEvent`` allows you to act on the:class:`Symfony\\Component\\\Mailer\\\SentMessage`
1725-
class to access the original message (``getOriginalMessage()``) and some debugging
1726-
information (``getDebug()``) such as the HTTP calls made by the HTTP transports,
1727-
which is useful for debugging errors::
1732+
class to access the original message (``getOriginalMessage()``) and some
1733+
:ref:`debugginginformation<mailer-debugging-emails>`(``getDebug()``) such as the HTTP calls
1734+
made by the HTTP transports,which is useful for debugging errors::
17281735

17291736
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17301737
use Symfony\Component\Mailer\Event\SentMessageEvent;
17311738

17321739
public function onMessage(SentMessageEvent $event): void
17331740
{
1734-
$message = $event->getMessage();
1741+
// e.g you can get mail id
1742+
$event->getMessage();
17351743

17361744
// do something with the message
17371745
}
@@ -1743,6 +1751,8 @@ and their priorities:
17431751
17441752
$ php bin/console debug:event-dispatcher "Symfony\Component\Mailer\Event\SentMessageEvent"
17451753
1754+
.. _mailer-failed-message-event:
1755+
17461756
FailedMessageEvent
17471757
~~~~~~~~~~~~~~~~~~
17481758

@@ -1752,15 +1762,21 @@ FailedMessageEvent
17521762

17531763
The ``FailedMessageEvent`` event was introduced in Symfony 6.2.
17541764

1755-
``FailedMessageEvent`` allows acting on the initial message in case of a failure::
1765+
``FailedMessageEvent`` allows acting on the initial message in case of a failure and some
1766+
:ref:`debugging information<mailer-debugging-emails>` (``getDebug()``) such as the HTTP calls made
1767+
by the HTTP transports, which is useful for debugging errors::
17561768

17571769
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17581770
use Symfony\Component\Mailer\Event\FailedMessageEvent;
1771+
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
17591772

17601773
public function onMessage(FailedMessageEvent $event): void
17611774
{
17621775
// e.g you can get more information on this error when sending an email
1763-
$event->getError();
1776+
$error = $event->getError();
1777+
if ($error instanceof TransportExceptionInterface) {
1778+
$error->getDebug();
1779+
}
17641780

17651781
// do something with the message
17661782
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp