开发者

Swiftmailer and Symfony2

Having some problems implementing swiftmaile开发者_C百科r with the 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 the error

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

does anyone have any idea what i can do to fix this?


$mailer is an instance of the Swift_Mailer class (which is the class used for sending messages), but for creating a message, you need the Swift_Message class.

$message = Swift_Message::newInstance()

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜