diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 8cb557fb7d35d..35ca155fd7a7e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2527,16 +2527,18 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co } } - $webhookRequestParsers = [ - MailgunRequestParser::class => 'mailer.webhook.request_parser.mailgun', - PostmarkRequestParser::class => 'mailer.webhook.request_parser.postmark', - ]; + if ($webhookEnabled) { + $webhookRequestParsers = [ + MailgunRequestParser::class => 'mailer.webhook.request_parser.mailgun', + PostmarkRequestParser::class => 'mailer.webhook.request_parser.postmark', + ]; - foreach ($webhookRequestParsers as $class => $service) { - $package = substr($service, \strlen('mailer.transport_factory.')); + foreach ($webhookRequestParsers as $class => $service) { + $package = substr($service, \strlen('mailer.transport_factory.')); - if (!ContainerBuilder::willBeAvailable(sprintf('symfony/%s-mailer', 'gmail' === $package ? 'google' : $package), $class, ['symfony/framework-bundle', 'symfony/mailer'])) { - $container->removeDefinition($service); + if (!ContainerBuilder::willBeAvailable(sprintf('symfony/%s-mailer', 'gmail' === $package ? 'google' : $package), $class, ['symfony/framework-bundle', 'symfony/mailer'])) { + $container->removeDefinition($service); + } } }