Alexandru-Emil Lupu wrote:
> HI!
> i am using symfony 1.4 RC2 and i have met following problems on swift mailer:
> 
> by reading the doc here :
> http://www.symfony-project.org/tutorial/1_4/en/whats-new
> I have saw that swiftmailer is available, but no details about instalation:
> So, i have landed on this page:
> http://www.symfony-project.org/cookbook/1_2/en/email

This page is for symfony 1.2, not 1.3/1.4.

Swift Mailer is installed by default with symfony 1.3/1.4.

You can read Jobeet day 16 for more information about Swift Mailer, and 
the facotires.yml reference guide.

Fabien

> 
> Again, here, after reading the page, i have found that i have to
> manually install swift mailer. And i have done this. After install, i
> have wrote this piece of code ...
> 
>     $mail = $this->getMailer()->compose();
> 
>     $mail->setSubject(sfClientToolsHelper::__('reset password service'));
>     $mail->setTo(array(
>       $user->getProfile()->getEmail() => $user->getProfile()->getFullName()
>     ));
>     $mail->setFrom(epCustomConfig::getResetPasswordFromEmailAddress());
> 
>     $images = array();
>     $imagesRef = array();
> 
>     $images['ep'] = new Swift_Message_Image(new
> Swift_File(sfConfig::get('sf_web_dir') . '/images/mylogo.png'));
> 
>     foreach ($images as $name => $image)
>     {
>       $imagesRef[$name] = $mail->attach($image);
>     }
> 
>     $parameters = array(
>       'images' => $imagesRef , 'user' => $user , 'new_password' => 
> $new_password
>     );
> 
>     $html = $this->getPartial('mail/mailForgotPasswordHtml', $parameters);
>     $text = $this->getPartial('mail/mailForgotPasswordText', $parameters);
> 
>     $mail->setBody($html, 'text/html');
>     $mail->addPart($text, 'text/plain');
> 
>     $this->getMailer()->send($mail);
> 
> 
> When i have test it, i got this error:
> 
> Fatal error: Class 'Swift_Message_Image' not found in
> /project_path/apps/frontend/modules/sfGuardAuth/actions/actions.class.php
> on line 83
> 
> So, i have started to Google it, and i have found out that i have to
> insert this in my autoload.yml file
> 
> autoload:
>   swiftmailer:
>     name:      swiftmailer
>     path:      %SF_SYMFONY_LIB_DIR%/vendor/swift
>     recursive: true
> 
> but, again i got same error. I have found that this class comes in the
> swift installation according to the book, so i have updated my
> autoload.yml file to:
> 
> autoload:
>   swift:
>     name:      swift
>     path:      %SF_LIB_DIR%/vendor/swift
>     recursive: true
> 
> The good news are the fact that i don't get this error, but i get another one.
> 
> Catchable fatal error: Argument 1 passed to
> Swift_Transport_AbstractSmtpTransport::registerPlugin() must be an
> instance of Swift_Events_EventListener, instance of
> sfMailerMessageLoggerPlugin given, called in
> /project_path/lib/vendor/symfony/lib/mailer/sfMailer.class.php on line
> 140 and defined in
> /project_path/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/AbstractSmtpTransport.php
> on line 247
> 
> Catchable fatal error: Argument 1 passed to
> Swift_Events_SimpleEventDispatcher::bindEventListener() must be an
> instance of Swift_Events_EventListener, instance of
> sfMailerMessageLoggerPlugin given, called in
> /project_path/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/AbstractSmtpTransport.php
> on line 249 and defined in
> /project_path/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Events/SimpleEventDispatcher.php
> on line 123
> 
> and finally:
> 
> Fatal error: Call to undefined method Swift_Message::newinstance()
> in/project_path/lib/vendor/symfony/lib/mailer/sfMailer.class.php on
> line 237
> 
> So, i have get back to my factories.yml, where i had this config:
> 
>   mailer:
>     class: sfMailer
>     param:
>       logging:           %SF_LOGGING_ENABLED%
>       charset:           %SF_CHARSET%
>       delivery_strategy: spool
>       spool_class:       Swift_DoctrineSpool
>       spool_arguments:   [ MailMessage, message ]
>       transport:
>         class: Swift_SmtpTransport
>         param:
>           host:       localhost
>           port:       25
>           encryption: ~
>           username:  username
>           password:   a simple pass
> 
> and i have commented out the "logging" section but i still did not
> elude the problem with the first catchable fatal error.
> 
> I have get back to my autoload, and i have added a new entry
> 
> autoload:
>   swift:
>     name:      swift
>     path:      %SF_LIB_DIR%/vendor/swift
>     recursive: true
>   swiftmailer:
>     name:      swiftmailer
>     path:      %SF_SYMFONY_LIB_DIR%/vendor/swiftmailer
>     recursive: true
> 
> Now, all went fine until a moment ... after that i got :
> 
> Catchable fatal error: Argument 1 passed to
> Swift_Mime_SimpleMessage::attach() must implement interface
> Swift_Mime_MimeEntity, instance of Swift_Message_Image given, called
> in/project_path/apps/frontend/modules/sfGuardAuth/actions/actions.class.php
> on line 87 and defined
> in/project_path/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Mime/SimpleMessage.php
> on line 485
> 
> Fatal error: Call to undefined method
> Swift_Message_Image::getNestingLevel() in
> /project_path/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Mime/SimpleMimeEntity.php
> on line 693
> 
> 
> And now, I got stuck...
> Any ideeas how to solve this ?
> 
> By removing the image would solve this problem, however, i will not be
> able to send embeded images in my email ... at least following the
> tutorial.
> 
> Finally i have sent the email, however, based on config, you can see
> that i am sending messages by using spool as delivery strategy. I have
> got in my command line, and i have tried to send the email ... using
> 
> symfony project:send-emails --application=frontend
> 
> And, unfortunately got another problem:
> 
>  You can only send messages in the spool if the delivery strategy is
> "spool" (none is the current strategy).
> 
> Now, assuming that i have done something terrible wrong ... based on
> my errors and my provided code... could you tell me what I have done
> wrong ?
> 
> I am using:
> 
> PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23
> 2009 14:35:05)
> Copyright (c) 1997-2008 The PHP Group
> Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
>     with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans
> 
> symfony version 1.4.0-DEV
> 
> ubuntu 9.04 box
> 
> 
> Sorry for my long email.
> Thanks in advance.
> 
> Alecs
> 
> --
> Have a nice day!
> Alecs
> 
> As programmers create bigger & better idiot proof programs, so the
> universe creates bigger & better idiots!
> I am on web:  http://www.alecslupu.ro/
> I am on twitter: http://twitter.com/alecslupu
> I am on linkedIn: http://www.linkedin.com/in/alecslupu
> Tel: (+4)0748.543.798
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "symfony developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/symfony-devs?hl=en.
> 
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en.


Reply via email to