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

Commit

Permalink
Allow multilple delivery_address addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
jorns committed Dec 9, 2015
1 parent 3d21ada commit a981458
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
12 changes: 11 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,17 @@ private function getMailersNode()
->end()
->end()
->scalarNode('sender_address')->end()
->scalarNode('delivery_address')->end()
->variableNode('delivery_address')
->info('Forces the to: header can be a single email "[email protected]" or an array of delivery addresses')
->validate()
->ifTrue(
function ($value) {
return !is_array($value) && !is_string($value);
}
)
->thenInvalid('Delivery address must be either an array of email addresses or a singe email address.')
->end()
->end()
->arrayNode('antiflood')
->children()
->scalarNode('threshold')->defaultValue(99)->end()
Expand Down
4 changes: 4 additions & 0 deletions Resources/config/schema/swiftmailer-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="delivery-address">
<xsd:restriction base="xsd:string"></xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="auth_mode">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="plain" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$container->loadFromExtension('swiftmailer', array(
'delivery_address' => array('[email protected]', '[email protected]')
));
12 changes: 12 additions & 0 deletions Tests/DependencyInjection/Fixtures/config/xml/redirect_multi.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">

<swiftmailer:config>
<swiftmailer:delivery-address>[email protected]</swiftmailer:delivery-address>
<swiftmailer:delivery-address>[email protected]</swiftmailer:delivery-address>
</swiftmailer:config>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
swiftmailer:
delivery_address: [[email protected], [email protected]]
11 changes: 11 additions & 0 deletions Tests/DependencyInjection/SwiftmailerExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ public function testSingleRedirectionConfig($type)
$this->assertEquals(array('/foo@.*/'), $container->getParameter('swiftmailer.mailer.default.delivery_whitelist'));
}

/**
* @dataProvider getConfigTypes
*/
public function testMultiRedirectionConfig($type)
{
$container = $this->loadContainerFromFile('redirect_multi', $type);

$this->assertSame(array('swiftmailer.default.plugin' => array(array())), $container->getDefinition('swiftmailer.mailer.default.plugin.redirecting')->getTags());
$this->assertSame(array('[email protected]', '[email protected]'), $container->getParameter('swiftmailer.mailer.default.single_address'));
}

/**
* @dataProvider getConfigTypes
*/
Expand Down

0 comments on commit a981458

Please sign in to comment.