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

Appearance settings

[Mailer] Redundant MessageEvent dispatch #34972

Copy link
Copy link
Closed
@raneomik

Description

@raneomik
Issue body actions

Symfony version(s) affected: 4.4.1

Description

When only one email is sent in a Symfony application having also the Messenger component, two MessageEvents are actually dispatched.
Not sure if it is a bug or it is done on purpose, but it brings some confusion in the Web profiler where it shows a queued email in a "[main]" transport :

image

Seen also in functional tests using non-mocked, by default injected dependencies and checking sent emails count through dispatched events.

How to reproduce

In a Symfony 4.4 application in development mode (web profiler and debug activated), having Messenger component, and an implemented Mailer.
When an email is sent and Mailer is configured for 1 dsn, it should show 2 emails in web profiler, one sent by the actual configured dsn, and one queued in a "[main]" transport.

Possible Solution
Remove the MessageEvent dispatch in Symfony\Component\Mailer\Mailer:send and keep only the Messenger's MessageBus dispatch.

Additional context
The 2 MessageEvents come from :

  • dispatched in Symfony\Component\Mailer\Transport\AbstractTransport:send
  • in Symfony\Component\Mailer\Mailer:send - if MessageBus is not null (the dispatched transport in MessageEvent is an instance of Symfony\Component\Mailer\Transport\Transports)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.