Skip to content
This repository was archived by the owner on Feb 6, 2022. It is now read-only.

Fixing check for swiftmailer in EmailSenderListener #313

Merged
merged 1 commit into from
Feb 6, 2022

Conversation

mklewitz
Copy link
Contributor

When sending emails by injecting \Swift_Mailer and using the memory spool, no mails are sent out. There are no visible errors and mails are shown as correctly spooled in the profiler. However, the mails are never sent.

That is because the check for $container->has('mailer') in EmailSenderListener is always false at least with swiftmailer-bundle 3.5.2 on symfony 2.5.2. Additionally checking for 'swiftmailer.mailer.default' fixes the issue.

@fabpot
Copy link
Member

fabpot commented Mar 25, 2021

Can you check on a recent version of Symfony? 3.5 is very old and not maintained anymore.

@mklewitz
Copy link
Contributor Author

Actually I'm using the newest stable releases. 3.5.2 is the version of swiftmailer-bundle. And the 2.5.2 should've been 5.2.5. Sorry for the typo.

@mklewitz
Copy link
Contributor Author

To make the problem clearer:
When I inject ContainerInterface as $container this is what happens:

var_dump($container->has('mailer'));
var_dump($container->has('swiftmailer.mailer'));
var_dump($container->has('swiftmailer.mailer.default'));

results in:

bool(false) bool(false) bool(true)

However, bin/console debug:container results in:

  mailer                                                                               alias for "mailer.mailer"
  swiftmailer.mailer                                                                   alias for "swiftmailer.mailer.default"
  swiftmailer.mailer.default                                                           Swift_Mailer

@marphi
Copy link

marphi commented Aug 3, 2021

I would like to confirm that issue.

When we added to our project (based on symfony 4.4.26) symfony/mailer, mailer alias has been pointed to Symfony\Component\Mailer\Mailer and has been inlined. Execution of $this->container->has('mailer') has been return false.

So as a result of that memory spool has been stop sending emails.
This PR fixes the memory spool.

@fabpot
Copy link
Member

fabpot commented Feb 6, 2022

Thank you @mklewitz.

@fabpot fabpot merged commit e6033c8 into symfony:main Feb 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants