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 = '[email protected]'; //$user->getEmail();
$message = $mailer::newInstance()
->setSubject('New Password')
->setFrom('Neokeo <[email protected]>')
->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?
Swift Mailer is a component based library for sending e-mails from PHP applications.
Laravel provides a clean, simple API over the popular SwiftMailer library. Laravel provides drivers for SMTP, Mailgun, Mandrill, Amazon SES, PHP's mail function, and sendmail , allowing you to quickly get started sending mail through a local or cloud based service of your choice.
Symfony's Mailer & Mime components form a powerful system for creating and sending emails - complete with support for multipart messages, Twig integration, CSS inlining, file attachments and a lot more. Get them installed with: $ composer require symfony/mailer.
$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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With