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
* **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'.
......
......@@ -56,12 +56,12 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
);
$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']);
......@@ -71,6 +71,10 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
$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;
};
......@@ -89,6 +93,8 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
$app['swiftmailer.transport.eventdispatcher'] = function () {
return new \Swift_Events_SimpleEventDispatcher();
};
$app['swiftmailer.sender_address'] = null;
}
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