Commit 222592a3 authored by Fabien Potencier's avatar Fabien Potencier

feature #1182 added sender_address to switfmailer provider (fabpot)

This PR was merged into the 2.0.x-dev branch.

Discussion
----------

added sender_address to switfmailer provider

fixes #1022

Commits
-------

cbe94829 added sender_address to switfmailer provider
parents ac4317cf cbe94829
...@@ -12,9 +12,13 @@ Parameters ...@@ -12,9 +12,13 @@ Parameters
* **swiftmailer.use_spool**: A boolean to specify whether or not to use the * **swiftmailer.use_spool**: A boolean to specify whether or not to use the
memory spool, defaults to true. memory spool, defaults to true.
* **swiftmailer.options**: An array of options for the default SMTP-based * **swiftmailer.options**: An array of options for the default SMTP-based
configuration. 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: The following options can be set:
* **host**: SMTP hostname, defaults to 'localhost'. * **host**: SMTP hostname, defaults to 'localhost'.
......
...@@ -56,12 +56,12 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe ...@@ -56,12 +56,12 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
); );
$options = $app['swiftmailer.options'] = array_replace(array( $options = $app['swiftmailer.options'] = array_replace(array(
'host' => 'localhost', 'host' => 'localhost',
'port' => 25, 'port' => 25,
'username' => '', 'username' => '',
'password' => '', 'password' => '',
'encryption' => null, 'encryption' => null,
'auth_mode' => null, 'auth_mode' => null,
), $app['swiftmailer.options']); ), $app['swiftmailer.options']);
$transport->setHost($options['host']); $transport->setHost($options['host']);
...@@ -71,6 +71,10 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe ...@@ -71,6 +71,10 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
$transport->setPassword($options['password']); $transport->setPassword($options['password']);
$transport->setAuthMode($options['auth_mode']); $transport->setAuthMode($options['auth_mode']);
if (null !== $app['swiftmailer.sender_address']) {
$transport->registerPlugin(new \Swift_Plugins_ImpersonatePlugin($app['swiftmailer.sender_address']));
}
return $transport; return $transport;
}; };
...@@ -89,6 +93,8 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe ...@@ -89,6 +93,8 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
$app['swiftmailer.transport.eventdispatcher'] = function () { $app['swiftmailer.transport.eventdispatcher'] = function () {
return new \Swift_Events_SimpleEventDispatcher(); return new \Swift_Events_SimpleEventDispatcher();
}; };
$app['swiftmailer.sender_address'] = null;
} }
public function subscribe(Container $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment