I wish implementer a contact form on my website. i followed the symfony2 documentation : http://symfony.com/fr/doc/current/cookbook/email/email.html
i use symfony 2.3.3.
So that is my config_dev.yml:
swiftmailer:
transport: sendmail
My contactAction controller:
public function contactAction(Request $request)
{
$this->focus = "contact";
$form = $this->createFormBuilder()
->add('Sujet:', 'text')
->add('Service:', 'choice',
array(
'choices' =>
array(
'all' => 'Communication multi-canaux (plusieurs services liés)',
'web' => 'Développement Web',
'webMarketing' => 'Web Marketing',
'mobile' => 'Développement mobile / tablette',
'brand' => 'Brand design',
'event' => 'Evènementiel',
'print' => 'Campagne print',
),
'preferred_choices' => array('all'),
)
)
->add('Nom:', 'text')
->add('Societe:', 'text')
->add('Courriel:', 'email')
->add('message:', 'textarea')
->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
// Les données sont un tableau avec les clés "name", "email", et "message"
$data = $form->getData();
$message = \Swift_Message::newInstance()
->setSubject($data['Sujet'] . $data['Société'])
->setFrom($data['Courriel'])
->setTo('contact@visual-immersion.com')
->setBody($this->renderView('text à placer par la suite'))
;
$this->get('mailer')->send($message);
}
$this->get('mailer')->send($message);
return $this->render('VisualImmersionSiteBundle:Site:contact.html.twig',
array(
'focus' => $this->focus,
'form' => $form->createView(),
));
}
i have this error:
Catchable Fatal Error: Argument 2 passed to Swift_Transport_SendmailTransport::__construct() must implement interface Swift_Events_EventDispatcher, instance of Swift_Transport_StreamBuffer given, called in /var/www/visual-immersion/app/cache/dev/appDevDebugProjectContainer.php on line 2129 and defined in /var/www/visual-immersion/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php line 42
and I absolutely can not find where the problem is. Do you have any ideas, or have you experienced this error?
Thank you for your help
UPDATE:
i downgraded SwiftMailer package to 2.3.2 version in composer. The problem was solved, but now, i have this error message;
Expected response code 220 but got code "", with message ""
any idea ?