Permalink
Browse files

Merge pull request #19 from lstrojny/delivery-whitelist

Allow specifying delivery whitelists for the redirect plugin
  • Loading branch information...
2 parents fcacc9e + 3930be7 commit d2eae9385c029cbac031a90e6d2abc74b889a562 @stof stof committed Aug 29, 2012
Showing with 394 additions and 25 deletions.
  1. +7 −0 DependencyInjection/Configuration.php
  2. +1 −0 DependencyInjection/SwiftmailerExtension.php
  3. +4 −3 Resources/config/schema/swiftmailer-1.0.xsd
  4. +1 −0 Resources/config/swiftmailer.xml
  5. +4 −0 Tests/DependencyInjection/Fixtures/config/php/antiflood.php
  6. +2 −0 Tests/DependencyInjection/Fixtures/config/php/empty.php
  7. +16 −0 Tests/DependencyInjection/Fixtures/config/php/full.php
  8. +4 −0 Tests/DependencyInjection/Fixtures/config/php/null.php
  9. +5 −0 Tests/DependencyInjection/Fixtures/config/php/redirect.php
  10. +5 −0 Tests/DependencyInjection/Fixtures/config/php/redirect_single.php
  11. +13 −0 Tests/DependencyInjection/Fixtures/config/php/smtp.php
  12. +4 −0 Tests/DependencyInjection/Fixtures/config/php/spool.php
  13. +4 −0 Tests/DependencyInjection/Fixtures/config/php/spool_memory.php
  14. +11 −0 Tests/DependencyInjection/Fixtures/config/xml/antiflood.xml
  15. +9 −0 Tests/DependencyInjection/Fixtures/config/xml/empty.xml
  16. +25 −0 Tests/DependencyInjection/Fixtures/config/xml/full.xml
  17. +9 −0 Tests/DependencyInjection/Fixtures/config/xml/null.xml
  18. +12 −0 Tests/DependencyInjection/Fixtures/config/xml/redirect.xml
  19. +11 −0 Tests/DependencyInjection/Fixtures/config/xml/redirect_single.xml
  20. +20 −0 Tests/DependencyInjection/Fixtures/config/xml/smtp.xml
  21. +11 −0 Tests/DependencyInjection/Fixtures/config/xml/spool.xml
  22. +11 −0 Tests/DependencyInjection/Fixtures/config/xml/spool_memory.xml
  23. +2 −0 Tests/DependencyInjection/Fixtures/config/yml/antiflood.yml
  24. +1 −0 Tests/DependencyInjection/Fixtures/config/yml/empty.yml
  25. +17 −0 Tests/DependencyInjection/Fixtures/config/yml/full.yml
  26. +2 −0 Tests/DependencyInjection/Fixtures/config/yml/null.yml
  27. +5 −0 Tests/DependencyInjection/Fixtures/config/yml/redirect.yml
  28. +4 −0 Tests/DependencyInjection/Fixtures/config/yml/redirect_single.yml
  29. +11 −0 Tests/DependencyInjection/Fixtures/config/yml/smtp.yml
  30. +2 −0 Tests/DependencyInjection/Fixtures/config/yml/spool.yml
  31. +3 −0 Tests/DependencyInjection/Fixtures/config/yml/spool_memory.yml
  32. +154 −20 Tests/DependencyInjection/SwiftmailerExtensionTest.php
  33. +4 −2 composer.json
@@ -83,6 +83,13 @@ public function getConfigTreeBuilder()
->end()
->end()
->scalarNode('delivery_address')->end()
+ ->end()
+ ->fixXmlConfig('delivery_whitelist_pattern', 'delivery_whitelist')
+ ->children()
+ ->arrayNode('delivery_whitelist')
+ ->prototype('scalar')
+ ->end()
+ ->end()
->booleanNode('disable_delivery')->end()
->booleanNode('logging')->defaultValue($this->debug)->end()
->end()
@@ -126,6 +126,7 @@ public function load(array $configs, ContainerBuilder $container)
} else {
$container->setParameter('swiftmailer.single_address', null);
}
+ $container->setParameter('swiftmailer.delivery_whitelist', $config['delivery_whitelist']);
}
/**
@@ -8,10 +8,11 @@
<xsd:element name="config" type="config" />
<xsd:complexType name="config">
- <xsd:all>
- <xsd:element name="spool" type="spool" minOccurs="0" maxOccurs="1" />
+ <xsd:sequence>
<xsd:element name="antiflood" type="antiflood" minOccurs="0" maxOccurs="1" />
- </xsd:all>
+ <xsd:element name="spool" type="spool" minOccurs="0" maxOccurs="1" />
+ <xsd:element name="delivery-whitelist-pattern" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
<xsd:attribute name="username" type="xsd:string" />
<xsd:attribute name="password" type="xsd:string" />
@@ -63,6 +63,7 @@
<service id="swiftmailer.plugin.redirecting" class="%swiftmailer.plugin.redirecting.class%" public="false">
<argument>%swiftmailer.single_address%</argument>
+ <argument>%swiftmailer.delivery_whitelist%</argument>
</service>
<service id="swiftmailer.plugin.antiflood" class="%swiftmailer.plugin.antiflood.class%" public="false">
@@ -0,0 +1,4 @@
+<?php
+$container->loadFromExtension('swiftmailer', array(
+ 'antiflood' => true
+));
@@ -0,0 +1,2 @@
+<?php
+$container->loadFromExtension('swiftmailer', array());
@@ -0,0 +1,16 @@
+<?php
+$container->loadFromExtension('swiftmailer', array(
+ 'transport' => "smtp",
+ 'username' =>"user",
+ 'password' => "pass",
+ 'host' => "example.org",
+ 'port' => "12345",
+ 'encryption' => "tls",
+ 'auth-mode' => "login",
+ 'timeout' => "1000",
+ 'source_ip' => "127.0.0.1",
+ 'logging' => true,
+ 'spool' => array('type' => 'memory'),
+ 'delivery_address' => 'single@host.com',
+ 'delivery_whitelist' => array('/foo@.*/', '/.*@bar.com$/'),
+));
@@ -0,0 +1,4 @@
+<?php
+$container->loadFromExtension('swiftmailer', array(
+ 'transport' => null
+));
@@ -0,0 +1,5 @@
+<?php
+$container->loadFromExtension('swiftmailer', array(
+ 'delivery_address' => 'single@host.com',
+ 'delivery_whitelist' => array('/foo@.*/', '/.*@bar.com$/'),
+));
@@ -0,0 +1,5 @@
+<?php
+$container->loadFromExtension('swiftmailer', array(
+ 'delivery_address' => 'single@host.com',
+ 'delivery_whitelist' => array('/foo@.*/'),
+));
@@ -0,0 +1,13 @@
+<?php
+$container->loadFromExtension('swiftmailer', array(
+ 'transport' => "smtp",
+ 'username' =>"user",
+ 'password' => "pass",
+ 'host' => "example.org",
+ 'port' => "12345",
+ 'encryption' => "tls",
+ 'auth-mode' => "login",
+ 'timeout' => "1000",
+ 'source_ip' => "127.0.0.1",
+ 'logging' => true,
+));
@@ -0,0 +1,4 @@
+<?php
+$container->loadFromExtension('swiftmailer', array(
+ 'spool' => true
+));
@@ -0,0 +1,4 @@
+<?php
+$container->loadFromExtension('swiftmailer', array(
+ 'spool' => array('type' => 'memory')
+));
@@ -0,0 +1,11 @@
+<?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:antiflood/>
+ </swiftmailer:config>
+</container>
@@ -0,0 +1,9 @@
+<?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/>
+</container>
@@ -0,0 +1,25 @@
+<?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
+ transport="smtp"
+ username="user"
+ password="pass"
+ host="example.org"
+ port="12345"
+ encryption="tls"
+ auth-mode="login"
+ timeout="1000"
+ source-ip="127.0.0.1"
+ logging="true"
+ delivery-address="single@host.com">
+ <swiftmailer:antiflood/>
+ <swiftmailer:spool type="memory"/>
+ <swiftmailer:delivery-whitelist-pattern>/foo@.*/</swiftmailer:delivery-whitelist-pattern>
+ <swiftmailer:delivery-whitelist-pattern>/.*@bar.com$/</swiftmailer:delivery-whitelist-pattern>
+ </swiftmailer:config>
+</container>
@@ -0,0 +1,9 @@
+<?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 transport="null"/>
+</container>
@@ -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 delivery-address="single@host.com">
+ <swiftmailer:delivery-whitelist-pattern>/foo@.*/</swiftmailer:delivery-whitelist-pattern>
+ <swiftmailer:delivery-whitelist-pattern>/.*@bar.com$/</swiftmailer:delivery-whitelist-pattern>
+ </swiftmailer:config>
+</container>
@@ -0,0 +1,11 @@
+<?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 delivery-address="single@host.com">
+ <swiftmailer:delivery-whitelist-pattern>/foo@.*/</swiftmailer:delivery-whitelist-pattern>
+ </swiftmailer:config>
+</container>
@@ -0,0 +1,20 @@
+<?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
+ transport="smtp"
+ username="user"
+ password="pass"
+ host="example.org"
+ port="12345"
+ encryption="tls"
+ auth-mode="login"
+ timeout="1000"
+ source-ip="127.0.0.1"
+ logging="true"/>
+</container>
@@ -0,0 +1,11 @@
+<?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:spool/>
+ </swiftmailer:config>
+</container>
@@ -0,0 +1,11 @@
+<?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:spool type="memory"/>
+ </swiftmailer:config>
+</container>
@@ -0,0 +1,2 @@
+swiftmailer:
+ antiflood: true
@@ -0,0 +1 @@
+swiftmailer:
@@ -0,0 +1,17 @@
+swiftmailer:
+ transport: smtp
+ username: user
+ password: pass
+ host: example.org
+ port: 12345
+ encryption: tls
+ auth-mode: login
+ timeout: 1000
+ source_ip: 127.0.0.1
+ logging: true
+ spool:
+ type: memory
+ delivery_address: single@host.com
+ delivery_whitelist:
+ - /foo@.*/
+ - /.*@bar.com$/
@@ -0,0 +1,2 @@
+swiftmailer:
+ transport: ~
@@ -0,0 +1,5 @@
+swiftmailer:
+ delivery_address: single@host.com
+ delivery_whitelist:
+ - /foo@.*/
+ - /.*@bar.com$/
@@ -0,0 +1,4 @@
+swiftmailer:
+ delivery_address: single@host.com
+ delivery_whitelist:
+ - /foo@.*/
@@ -0,0 +1,11 @@
+swiftmailer:
+ transport: smtp
+ username: user
+ password: pass
+ host: example.org
+ port: 12345
+ encryption: tls
+ auth-mode: login
+ timeout: 1000
+ source_ip: 127.0.0.1
+ logging: true
@@ -0,0 +1,2 @@
+swiftmailer:
+ spool: true
@@ -0,0 +1,3 @@
+swiftmailer:
+ spool:
+ type: memory
Oops, something went wrong.

0 comments on commit d2eae93

Please sign in to comment.