Skip to content

Commit 7ecbc9e

Browse files
nalysiuslyrixx
authored andcommitted
Add support for headers in native mailer
The native mailer is able to have additional headers, but it wasn't possible to give it any headers in the configuration. Swift mailer may have a content_type key but not native mailer. A new "headers" key is now allowed in the handler configuration, so a list of headers may be given to the handler. Only native mailer supports it. Related to #272
1 parent 5fe15c2 commit 7ecbc9e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

DependencyInjection/Configuration.php

+5
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
* - subject: string
176176
* - [level]: level name or int value, defaults to DEBUG
177177
* - [bubble]: bool, defaults to true
178+
* - [headers]: optional array containing additional headers
178179
*
179180
* - socket:
180181
* - connection_string: string
@@ -594,6 +595,10 @@ public function getConfigTreeBuilder()
594595
->end()
595596
->scalarNode('subject')->end() // swift_mailer and native_mailer
596597
->scalarNode('content_type')->defaultNull()->end() // swift_mailer
598+
->arrayNode('headers') // native_mailer
599+
->canBeUnset()
600+
->scalarPrototype()->end()
601+
->end()
597602
->scalarNode('mailer')->defaultValue('mailer')->end() // swift_mailer
598603
->arrayNode('email_prototype') // swift_mailer
599604
->canBeUnset()

DependencyInjection/MonologExtension.php

+3
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
540540
$handler['level'],
541541
$handler['bubble'],
542542
));
543+
if (!empty($handler['headers'])) {
544+
$definition->addMethodCall('addHeader', $handler['headers']);
545+
}
543546
break;
544547

545548
case 'socket':

Resources/config/schema/monolog-1.0.xsd

+7
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<xsd:attribute name="content-type" type="xsd:string" />
8989
<xsd:attribute name="webhook-url" type="xsd:string" />
9090
<xsd:attribute name="slack-team" type="xsd:string" />
91+
<xsd:attribute name="headers" type="headers" />
9192
</xsd:complexType>
9293

9394
<xsd:simpleType name="level">
@@ -186,4 +187,10 @@
186187
</xsd:choice>
187188
<xsd:attribute name="code" type="xsd:integer" />
188189
</xsd:complexType>
190+
191+
<xsd:complexType name="headers">
192+
<xsd:choice minOccurs="0" maxOccurs="unbounded">
193+
<xsd:element name="header" type="xsd:string" />
194+
</xsd:choice>
195+
</xsd:complexType>
189196
</xsd:schema>

0 commit comments

Comments
 (0)