Having some problems implementing swiftmailer 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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.