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

Commit

Permalink
bug #70 don't share the auth handler for all smtp transport (tecbot)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.2-dev branch (closes #70).

Discussion
----------

don't share the auth handler for all smtp transport

Currently it's not possible to use different auth parameters for multiple smtp transports because the auth handler is shared.

Commits
-------

86fb0c3 don't share the auth handler for all smtp transport
  • Loading branch information
fabpot committed Mar 14, 2014
2 parents b628a62 + 86fb0c3 commit e57fe9d
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 e57fe9d

Please sign in to comment.