Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.3.3][swiftMailer] Argument 2 passed to Swift_Transport_SendmailTransport::__construct() must implement interface Swift_Events_EventDispatcher #8700

Closed
ibasaw opened this issue Aug 8, 2013 · 15 comments

Comments

@ibasaw
Copy link

ibasaw commented Aug 8, 2013

hi

on sf2.3.3, i try today to send email as i do on sf2.1, and got this message, se below:

in my composer.json got this

    "php": ">=5.3.3",
    "symfony/symfony": "2.3.*",
    "doctrine/orm": ">=2.2.3,<2.4-dev",
    "doctrine/doctrine-bundle": "1.2.*@dev",
    "twig/extensions": "1.0.*",
    "symfony/assetic-bundle": "2.3.*",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "2.3.*",
    "sensio/distribution-bundle": "2.3.*",
    "sensio/framework-extra-bundle": "2.3.*",
    "sensio/generator-bundle": "2.3.*",
    "incenteev/composer-parameter-handler": "~2.0",

"jms/serializer-bundle": "0.12.*@dev",
"jms/di-extra-bundle": "1.4.*@dev",
"jms/security-extra-bundle": "1.5.*@dev",
"doctrine/data-fixtures": "1.0.*@dev",
"doctrine/doctrine-fixtures-bundle": "2.1.*@dev",

the command in cli

php -v
PHP 5.4.17-pl0-gentoo (cli) (built: Jul 29 2013 11:55:58)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with XCache v3.0.1, Copyright (c) 2005-2013, by mOo
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
with XCache Optimizer v3.0.1, Copyright (c) 2005-2013, by mOo
with XCache Cacher v3.0.1, Copyright (c) 2005-2013, by mOo
with XCache Coverager v3.0.1, Copyright (c) 2005-2013, by mOo



php app/console swiftmailer:spool:send
Processing default mailer... PHP Catchable fatal error:  Argument 2 passed to Swift_Transport_SendmailTransport::__construct() must implement interface Swift_Events_EventDispatcher, instance of Swift_Transport_StreamBuffer given, called in /home/www/_v2/symfony/app/cache/dev/appDevDebugProjectContainer.php on line 7952 and defined in /home/www/_v2/symfony/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php on line 42
PHP Stack trace:
PHP   1. {main}() /home/www/_v2/symfony/app/console:0
PHP   2. Symfony\Component\Console\Application->run() /home/www/_v2/symfony/app/console:22
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /home/www/_v2/symfony/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
PHP   4. Symfony\Component\Console\Application->doRun() /home/www/_v2/symfony/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/www/_v2/symfony/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
PHP   6. Symfony\Component\Console\Command\Command->run() /home/www/_v2/symfony/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:904
PHP   7. Symfony\Bundle\SwiftmailerBundle\Command\SendEmailCommand->execute() /home/www/_v2/symfony/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:244
PHP   8. Symfony\Bundle\SwiftmailerBundle\Command\SendEmailCommand->processMailer() /home/www/_v2/symfony/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php:60
PHP   9. Symfony\Component\DependencyInjection\Container->get() /home/www/_v2/symfony/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Command/SendEmailCommand.php:88
PHP  10. appDevDebugProjectContainer->getSwiftmailer_Mailer_Default_Transport_RealService() /home/www/_v2/symfony/app/bootstrap.php.cache:1935
PHP  11. Swift_Transport_SendmailTransport->__construct() /home/www/_v2/symfony/app/cache/dev/appDevDebugProjectContainer.php:7952
@yvh
Copy link
Contributor

yvh commented Aug 9, 2013

Same error for me :-(

@ianfp
Copy link

ianfp commented Aug 9, 2013

Me too.

@jsampedro77
Copy link

One more here, but only on production server. Devel and staging working ok.
The error raises during a "app/console assets:install -e prod", same PHP version in all enviroments (5.4.16)

@khyor
Copy link

khyor commented Aug 9, 2013

hello !
same error for me on PHP Version 5.4.4.
After migration symfony 2.1 to 2.3.3, swift mailer doesn't work in dev or prod environnement with mail or sendmail transport.
But work with smtp gmail account.

@RA-dim
Copy link

RA-dim commented Aug 10, 2013

I got same error. For now, downgrade swiftmailer resolves problem...
"symfony/symfony": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.2",

@ibasaw
Copy link
Author

ibasaw commented Aug 12, 2013

it works on 2.3.2....thank you !

Should i closed this issue ?

@khyor
Copy link

khyor commented Aug 12, 2013

indeed ! it's works ! thx

@WedgeSama
Copy link
Contributor

I have got the same issue.

To @ibasaw , do not close the issue cause just downgrade swiftmailer as provide @RA-dim is just a temp solution. We need to fix the bug.

@giosh94mhz
Copy link
Contributor

I've investigated the issue a bit.

The source of the problem is that the transport constructor is called with 3 parameters.

  1. When using mail transport:
    Swift_Transport_MailTransport ->__construct (object(Swift_Transport_SimpleMailInvoker), object(Swift_Transport_SimpleMailInvoker), object(Swift_Events_SimpleEventDispatcher))

  2. When using sendmail transport:
    Swift_Transport_SendmailTransport ->__construct (object(Swift_Transport_StreamBuffer), object(Swift_Transport_StreamBuffer), object(Swift_Events_SimpleEventDispatcher))

The first parameters is created and added twice during dependencies injection.
I can't provide a patch since I'm a Symfony newbie and don't fully understand the framework yet.

Anyway, I've backtracked what triggers the two instances with the possible patches.

  1. By removing the argument tag in swiftmailer.xml:
diff --git a/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Resources/config/swiftmailer.xml b/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Resources/config/swiftmailer.xml
index 6093542..c5d2037 100644
--- a/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Resources/config/swiftmailer.xml
+++ b/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Resources/config/swiftmailer.xml
@@ -36,11 +36,9 @@
         </service>

         <service id="swiftmailer.transport.sendmail.abstract" class="%swiftmailer.transport.sendmail.class%" abstract="true" public="false">
-            <argument type="service" id="swiftmailer.transport.buffer" />
         </service>

         <service id="swiftmailer.transport.mail.abstract" class="%swiftmailer.transport.mail.class%" abstract="true" public="false">
-            <argument type="service" id="swiftmailer.transport.mailinvoker" />
         </service>

         <service id="swiftmailer.transport.null.abstract" class="Swift_Transport_NullTransport" abstract="true" public="false">
  1. By removing the reference in SwiftmailerExtension.php:
diff --git a/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php b/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php
index c8d24b6..5502bce 100644
--- a/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php
+++ b/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/DependencyInjection/SwiftmailerExtension.php
@@ -139,7 +139,6 @@ class SwiftmailerExtension extends Extension
             $container
                 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport), $definitionDecorator)
                 ->setArguments(array(
-                    new Reference('swiftmailer.transport.buffer'),
                     new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)),
                 ))
             ;
@@ -149,7 +148,6 @@ class SwiftmailerExtension extends Extension
             $container
                 ->setDefinition(sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport), $definitionDecorator)
                 ->setArguments(array(
-                    new Reference('swiftmailer.transport.mailinvoker'),
                     new Reference(sprintf('swiftmailer.mailer.%s.transport.eventdispatcher', $name)),
                 ))
             ;

I've tested both solutions and they work for me. Maybe this are just workaround, but hope this will help.

@nnmer
Copy link

nnmer commented Aug 16, 2013

I got same error. But only downgrade to swiftmailer 2.3.1 resolves problem...
"symfony/symfony": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.1",

@XWB
Copy link
Contributor

XWB commented Aug 19, 2013

Same problem, downgrading to swiftmailer-bundle 2.3.2 resolves the issue.

Ping @fabpot

@fabpot
Copy link
Member

fabpot commented Aug 22, 2013

fixed now

@fabpot fabpot closed this as completed Aug 22, 2013
@ibasaw
Copy link
Author

ibasaw commented Aug 22, 2013

version of swfitmailer work on 2.3.2, but don't on 2.3.3

"symfony/swiftmailer-bundle": "2.3.2"

@webspin
Copy link

webspin commented Aug 27, 2013

+1

1 similar comment
@comur
Copy link

comur commented Sep 20, 2013

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests