diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index ea64157fde9b..86eb3bb79855 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -1525,6 +1525,22 @@ private function addMailerSection(ArrayNodeDefinition $rootNode)
->{!class_exists(FullStack::class) && class_exists(Mailer::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->children()
->scalarNode('dsn')->defaultValue('smtp://null')->end()
+ ->arrayNode('envelope')
+ ->info('Mailer Envelope configuration')
+ ->children()
+ ->scalarNode('sender')->end()
+ ->arrayNode('recipients')
+ ->performNoDeepMerging()
+ ->beforeNormalization()
+ ->ifArray()
+ ->then(function ($v) {
+ return array_filter(array_values($v));
+ })
+ ->end()
+ ->prototype('scalar')->end()
+ ->end()
+ ->end()
+ ->end()
->end()
->end()
->end()
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 19386d9721ae..34ab211f04ef 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -1918,6 +1918,13 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
$loader->load('mailer.xml');
$container->getDefinition('mailer.default_transport')->setArgument(0, $config['dsn']);
+
+ $recipients = $config['envelope']['recipients'] ?? null;
+ $sender = $config['envelope']['sender'] ?? null;
+
+ $envelopeListener = $container->getDefinition('mailer.envelope_listener');
+ $envelopeListener->setArgument(0, $sender);
+ $envelopeListener->setArgument(1, $recipients);
}
/**
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.xml
index 1f567a6c93a7..cfe98f21dca0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.xml
@@ -25,5 +25,11 @@
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: