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

Commit

Permalink
don't share the auth handler for all smtp transport
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Adam authored and fabpot committed Mar 14, 2014
1 parent fcefa9d commit 86fb0c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions DependencyInjection/SwiftmailerExtension.php
Expand Up @@ -117,20 +117,28 @@ protected function configureMailerTransport($name, array $mailer, ContainerBuild
->setDefinition(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name), $definitionDecorator)
;
if ('smtp' === $transport) {
$authDecorator = new DefinitionDecorator('swiftmailer.transport.authhandler.abstract');
$container
->setDefinition(sprintf('swiftmailer.mailer.%s.transport.authhandler', $name), $authDecorator)
->addMethodCall('setUsername', array('%swiftmailer.mailer.' . $name . '.transport.smtp.username%'))
->addMethodCall('setPassword', array('%swiftmailer.mailer.' . $name . '.transport.smtp.password%'))
->addMethodCall('setAuthMode', array('%swiftmailer.mailer.' . $name . '.transport.smtp.auth_mode%'));

$bufferDecorator = new DefinitionDecorator('swiftmailer.transport.buffer.abstract');
$container
->setDefinition(sprintf('swiftmailer.mailer.%s.transport.buffer', $name), $bufferDecorator);

$definitionDecorator = new DefinitionDecorator('swiftmailer.transport.smtp.abstract');
$container
->setDefinition(sprintf('swiftmailer.mailer.%s.transport.smtp', $name), $definitionDecorator)
->setArguments(array(
new Reference('swiftmailer.transport.buffer'),
array(new Reference('swiftmailer.transport.authhandler')),
new Reference(sprintf('swiftmailer.mailer.%s.transport.buffer', $name)),
array(new Reference(sprintf('swiftmailer.mailer.%s.transport.authhandler', $name))),
new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)),
))
->addMethodCall('setHost', array('%swiftmailer.mailer.' . $name . '.transport.smtp.host%'))
->addMethodCall('setPort', array('%swiftmailer.mailer.' . $name . '.transport.smtp.port%'))
->addMethodCall('setEncryption', array('%swiftmailer.mailer.' . $name . '.transport.smtp.encryption%'))
->addMethodCall('setUsername', array('%swiftmailer.mailer.' . $name . '.transport.smtp.username%'))
->addMethodCall('setPassword', array('%swiftmailer.mailer.' . $name . '.transport.smtp.password%'))
->addMethodCall('setAuthMode', array('%swiftmailer.mailer.' . $name . '.transport.smtp.auth_mode%'))
->addMethodCall('setTimeout', array('%swiftmailer.mailer.' . $name . '.transport.smtp.timeout%'))
->addMethodCall('setSourceIp', array('%swiftmailer.mailer.' . $name . '.transport.smtp.source_ip%'))
;
Expand Down
4 changes: 2 additions & 2 deletions Resources/config/swiftmailer.xml
Expand Up @@ -49,11 +49,11 @@

<service id="swiftmailer.transport.mailinvoker" class="Swift_Transport_SimpleMailInvoker" public="false" />

<service id="swiftmailer.transport.buffer" class="Swift_Transport_StreamBuffer" public="false">
<service id="swiftmailer.transport.buffer.abstract" class="Swift_Transport_StreamBuffer" abstract="true" public="false">
<argument type="service" id="swiftmailer.transport.replacementfactory" />
</service>

<service id="swiftmailer.transport.authhandler" class="Swift_Transport_Esmtp_AuthHandler" public="false">
<service id="swiftmailer.transport.authhandler.abstract" class="Swift_Transport_Esmtp_AuthHandler" abstract="true" public="false">
<argument type="collection">
<argument type="service"><service class="Swift_Transport_Esmtp_Auth_CramMd5Authenticator" public="false" /></argument>
<argument type="service"><service class="Swift_Transport_Esmtp_Auth_LoginAuthenticator" public="false" /></argument>
Expand Down

0 comments on commit 86fb0c3

Please sign in to comment.