Answer the question
In order to leave comments, you need to log in
Why doesn't SwiftMailer Symfony2 work on hosting?
Hello.
I'm trying to set up sending a letter in symfony 2.8 via gmail.
The connection parameters are set like right
config.yml
swiftmailer:
transport: gmail
username: "%mailer_user%"
password: "%mailer_password%"
/**
* @Route("/email", name="email")
*/
public function emailAction()
{
$message = \Swift_Message::newInstance()
->setSubject('Contact enquiry')
->setFrom('[email protected]')
->setTo('[email protected]')
->setBody(
$this->renderView('TestBundle:Email:registration.html.twig', array('user' => 'user', 'pass'=>'test')),
'text/html'
);
//print_r($message);
$this->get('mailer')->send($message);
$em = $this->getDoctrine()->getManager();
$users = $em->getRepository('TestBundle:User')->findAll();
return $this->render('TestBundle:Default:admin.html.twig', array(
'users'=>$users
));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question