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

Commit

Permalink
Sendmail command to be customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
Herzmut committed Jul 24, 2017
1 parent 556ef62 commit cd4aca4
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/vendor/
/composer.lock

1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private function getMailersNode()
->children()
->scalarNode('url')->defaultNull()->end()
->scalarNode('transport')->defaultValue('smtp')->end()
->scalarNode('command')->defaultValue('/usr/sbin/sendmail -bs')->end()
->scalarNode('username')->defaultNull()->end()
->scalarNode('password')->defaultNull()->end()
->scalarNode('host')->defaultValue('localhost')->end()
Expand Down
3 changes: 3 additions & 0 deletions DependencyInjection/SwiftmailerTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public static function createTransport(array $options, RequestContext $requestCo
$eventDispatcher
);

$transport->setCommand($options['command']);

$smtpTransportConfigurator = new SmtpTransportConfigurator(null, $requestContext);
$smtpTransportConfigurator->configure($transport);
} elseif ('null' === $options['transport']) {
Expand Down Expand Up @@ -92,6 +94,7 @@ public static function resolveOptions(array $options)
'local_domain' => null,
'encryption' => null,
'auth_mode' => null,
'command' => null
);

if (isset($options['url'])) {
Expand Down
1 change: 1 addition & 0 deletions Resources/config/schema/swiftmailer-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<xsd:attribute name="disable-delivery" type="xsd:boolean" />
<xsd:attribute name="sender-address" type="xsd:boolean" />
<xsd:attribute name="url" type="xsd:string" />
<xsd:attribute name="command" type="xsd:string" />
</xsd:attributeGroup>

<xsd:complexType name="mailer">
Expand Down
1 change: 1 addition & 0 deletions Tests/DependencyInjection/Fixtures/config/php/sendmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
$container->loadFromExtension('swiftmailer', array(
'transport' => 'sendmail',
'local_domain' => 'local.example.org',
'command' => '/usr/sbin/sendmail -bs'
));
1 change: 1 addition & 0 deletions Tests/DependencyInjection/Fixtures/config/xml/sendmail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<swiftmailer:config
transport="sendmail"
local-domain="local.example.org"
command="/usr/sbin/sendmail -bs"
/>
</container>
1 change: 1 addition & 0 deletions Tests/DependencyInjection/Fixtures/config/yml/sendmail.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
swiftmailer:
transport: sendmail
local_domain: local.example.org
command: /usr/sbin/sendmail -bs
11 changes: 11 additions & 0 deletions Tests/DependencyInjection/SwiftmailerTransportFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function testCreateTransportWithSendmail()
{
$options = array(
'transport' => 'sendmail',
'command' => '/usr/sbin/sendmail -bs'
);

$transport = SwiftmailerTransportFactory::createTransport(
Expand Down Expand Up @@ -178,6 +179,7 @@ public function optionsAndResultExpected()
'transport' => 'null',
'username' => null,
'password' => null,
'command' => null,
'host' => null,
'port' => 25,
'timeout' => null,
Expand All @@ -196,6 +198,7 @@ public function optionsAndResultExpected()
'transport' => 'smtp',
'username' => 'user',
'password' => 'pass',
'command' => null,
'host' => 'host',
'port' => 1234,
'timeout' => null,
Expand All @@ -214,6 +217,7 @@ public function optionsAndResultExpected()
'transport' => 'sendmail',
'username' => 'username',
'password' => 'password',
'command' => null,
'host' => 'example.com',
'port' => 5678,
'timeout' => null,
Expand All @@ -232,6 +236,7 @@ public function optionsAndResultExpected()
'transport' => 'smtp',
'username' => 'user',
'password' => 'pass',
'command' => null,
'host' => 'host',
'port' => 1234,
'timeout' => 42,
Expand All @@ -248,6 +253,7 @@ public function optionsAndResultExpected()
'transport' => 'null',
'username' => null,
'password' => null,
'command' => null,
'host' => null,
'port' => 25,
'timeout' => null,
Expand All @@ -265,6 +271,7 @@ public function optionsAndResultExpected()
'transport' => 'smtp',
'username' => null,
'password' => null,
'command' => null,
'host' => null,
'port' => 25,
'timeout' => null,
Expand All @@ -282,6 +289,7 @@ public function optionsAndResultExpected()
'transport' => 'smtp',
'username' => null,
'password' => null,
'command' => null,
'host' => 'smtp.gmail.com',
'port' => 465,
'timeout' => null,
Expand All @@ -299,6 +307,7 @@ public function optionsAndResultExpected()
'transport' => 'sendmail',
'username' => null,
'password' => null,
'command' => null,
'host' => null,
'port' => 25,
'timeout' => null,
Expand All @@ -316,6 +325,7 @@ public function optionsAndResultExpected()
'transport' => 'null',
'username' => null,
'password' => null,
'command' => null,
'host' => null,
'port' => 465,
'timeout' => null,
Expand All @@ -333,6 +343,7 @@ public function optionsAndResultExpected()
'transport' => 'null',
'username' => null,
'password' => null,
'command' => null,
'host' => null,
'port' => 42,
'timeout' => null,
Expand Down

0 comments on commit cd4aca4

Please sign in to comment.