Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
added sender_address to switfmailer provider
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 13, 2015
1 parent ebe7e78 commit cbe9482
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions doc/providers/swiftmailer.rst
Expand Up @@ -12,9 +12,13 @@ Parameters

* **swiftmailer.use_spool**: A boolean to specify whether or not to use the
memory spool, defaults to true.

* **swiftmailer.options**: An array of options for the default SMTP-based
configuration.

* **swiftmailer.sender_address**: If set, all messages will be delivered with
this address as the "return path" address.

The following options can be set:

* **host**: SMTP hostname, defaults to 'localhost'.
Expand Down
16 changes: 11 additions & 5 deletions src/Silex/Provider/SwiftmailerServiceProvider.php
Expand Up @@ -56,12 +56,12 @@ public function register(Container $app)
);

$options = $app['swiftmailer.options'] = array_replace(array(
'host' => 'localhost',
'port' => 25,
'username' => '',
'password' => '',
'host' => 'localhost',
'port' => 25,
'username' => '',
'password' => '',
'encryption' => null,
'auth_mode' => null,
'auth_mode' => null,
), $app['swiftmailer.options']);

$transport->setHost($options['host']);
Expand All @@ -71,6 +71,10 @@ public function register(Container $app)
$transport->setPassword($options['password']);
$transport->setAuthMode($options['auth_mode']);

if (null !== $app['swiftmailer.sender_address']) {
$transport->registerPlugin(new \Swift_Plugins_ImpersonatePlugin($app['swiftmailer.sender_address']));
}

return $transport;
};

Expand All @@ -89,6 +93,8 @@ public function register(Container $app)
$app['swiftmailer.transport.eventdispatcher'] = function () {
return new \Swift_Events_SimpleEventDispatcher();
};

$app['swiftmailer.sender_address'] = null;
}

public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
Expand Down

0 comments on commit cbe9482

Please sign in to comment.