Hi Michael,
I had a similar problem - for me the issue was that the file
swift_init.php, which initializes the swiftmailer internal dependency
container, wasn't being included.

You could include it manually, but I think the cleaner way is to let
Symfony do it - basically you need to force the Symfony DIC to load
the 'mailer' service before you create a Swift_Message instance, and
then Symfony handles the include.  The best practice is probably to
inject the mailer into whatever service you're using to send mail.  If
you're sending mail directly from a controller, you could also just do
something quick and dirty like:

$mailer = $this->get('mailer');
// ... stuff with \Swift_Message

Hope this helps!
Kevin

On Apr 19, 1:34 pm, hollo <ho...@hollo.dk> wrote:
> Hi,
>
> I have found a weird problem, i dont really think it about
> swiftmailer, but with swiftmailer i can reproduce the error:
>
> When i initialize the swiftmailer class, i get an error.. i dont know
> if anyone can see if i does something wrong? As far as i can see it
> just as the manual says:
>
> http://symfony.com/doc/2.0/cookbook/email.html
>
> The "funny thing" is that i DONT see the error in my dev env, the
> class will be initialized just fine.. But when i initialize the class
> in prod env, i get an error saying:
>
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP
> Catchable fatal error:  Argument 1 passed to
> Swift_Mime_SimpleMessage::__construct() must be an instance of
> Swift_Mime_HeaderSet, none given in /var/www/atk_reg/vendor/
> swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php on line 30
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP Stack
> trace:
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP   1.
> {main}() /var/www/atk_reg/web/app.php:0
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP   2.
> Symfony\\Component\\HttpKernel\\Kernel->handle() /var/www/atk_reg/web/
> app.php:12
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP   3.
> Symfony\\Bundle\\FrameworkBundle\\HttpKernel->handle() /var/www/
> atk_reg/app/bootstrap.php.cache:587
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP   4.
> Symfony\\Component\\HttpKernel\\HttpKernel->handle() /var/www/atk_reg/
> vendor/symfony/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php:35
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP   5.
> Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw() /var/www/
> atk_reg/app/bootstrap.php.cache:400
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP   6.
> call_user_func_array() /var/www/atk_reg/app/bootstrap.php.cache:422
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP   7. ATK
> \\QuickpayBundle\\Controller\\DefaultController->checkoutAction() /var/
> www/atk_reg/app/bootstrap.php.cache:422
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP   8. ATK
> \\QuickpayBundle\\Controller\\DefaultController->sendMail() /var/www/
> atk_reg/src/ATK/QuickpayBundle/Controller/DefaultController.php:22
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP   9.
> Swift_Message::newInstance() /var/www/atk_reg/src/ATK/QuickpayBundle/
> Controller/DefaultController.php:260
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP  10.
> Swift_Message->__construct() /var/www/atk_reg/vendor/swiftmailer/lib/
> classes/Swift/Message.php:64
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP  11.
> call_user_func_array() /var/www/atk_reg/vendor/swiftmailer/lib/classes/
> Swift/Message.php:36
> [Tue Apr 19 22:16:31 2011] [error] [client 188.176.90.210] PHP  12.
> Swift_Mime_SimpleMessage->__construct() /var/www/atk_reg/vendor/
> swiftmailer/lib/classes/Swift/Message.php:36
>
> I can paste the code here, just for good practice:
>   public function sendMail($user)
>   {
>     $message = \Swift_Message::newInstance();
>     die('funny man');
>   }
>
> I have tried to find out what courses the problem, but i dont know.. i
> have tried on 2 different servers, running symfony PR11.. PHP 5.3,
> hope someone can help..
>
> Best regards,
> Michael Holm

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to