I wanted to send a test email by using Symfony 3.1 and SwiftMailer, but it doesn't work. I was reading other solutions, but it still doesn't work.
Config.yml:
swiftmailer:
transport: %mailer_transport%
encryption: %mailer_encryption%
auth_mode: %mailer_auth_mode%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
Parameters.yml
mailer_transport: smtp
mailer_encryption: ssl
mailer_auth_mode: login
mailer_host: smtp.gmail.com
mailer_user: [email protected]
mailer_password: mypass
Parameters.yml v.2 I was trying:
mailer_transport: gmail
mailer_encryption: ssl
mailer_auth_mode: login
mailer_host: smtp.gmail.com
mailer_user: [email protected]
mailer_password: mypass
Controller:
public function contactAction(Request $request)
{
$name = $request->request->get('name');
$surname = $request->request->get('surname');
$email = $request->request->get('email');
$subject = $request->request->get('subject');
$message = $request->request->get('message');
$data = "";
if($request->request->get('contact_submit')){
$message = \Swift_Message::newInstance()
->setSubject($subject)
->setFrom($email)
->setTo('[email protected]')
->setBody($message);
$this->get('mailer')->send($message);
$data = "Thank you: $name";
}
return $this->render('przedszkole/contact.html.twig', array('data' => $data));
}
So after click Submit, my view change and show me: Thank you $name, but i don't get any email :/
I change security lvl of my gmail e-mail like someone tell in other solutions, but it doesn't help for me :/
I also uncomment swiftmailer: delivery_adress in config_dev.yml.
I will be grateful for any help :/