Swiftmailer and Symfony2

Having some problems implementing swiftmailer with new symfony2 beta4, below is my code

$mailer = $this->container->get('mailer');
$name = ucwords(str_replace('.',' ', $user->getScreenName()));
$email = 'me@me.com'; //$user->getEmail();
$message = $mailer::newInstance()
        ->setSubject('New Password')
        ->setFrom('Neokeo <blah@blah.com>')
        ->setTo("$name <$email>")
        ->setBody($this->renderView('MyBundle:User:reset.html.php', array('user',$user)));

$mailer->send($message);

and mistake

Catchable fatal error: Argument 1 passed to Swift_Mailer::newInstance() must implement interface Swift_Transport, none given

Does anyone know what I can do to fix this?

+5
source share
1 answer

$maileris an instance of a class Swift_Mailer(which is the class used to send messages), but to create a message you need a class Swift_Message.

$message = Swift_Message::newInstance()

http://swiftmailer.org/docs/message-quickref

+9
source

All Articles