Need help with Swift mailer with Kohana wrapper

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-03-19T05:30:58Z Indexed on 2010/03/19 5:51 UTC
Read the original article Hit count: 773

Filed under:
|
|
|
|

My current code is this

$swift = email::connect();


        $swift->setSubject('hello')
              ->setFrom(array('[email protected]' => 'Alex'))
              ->setTo(array('[email protected]' => 'Alex'))
              ->setBody('hello')  
              ->attach(Swift_Attachment::fromPath(DOCROOT . 'assets/attachments/instructions.pdf'));

        $swift->send();

The email::connect() returns an instance of SwiftMailer.

As per these docs, it would seem that it should work.

However, I get an error

Fatal error: Call to undefined method Swift_Mailer::setSubject() in /home/user/public_html/application/classes/controller/properties.php  on line 45

I've seen that email::connect() does exactly what the example code in the docs does. That is

  • include the correct file
  • return an instance of the library

What am I doing wrong?

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about kohana