发送电子邮件在Synfony 3在需要帮助学习如何使用与Swift_mailer图书馆Symfony框架在开发模式下发送电子邮件。在开发模式
这里是我迄今为止
在config_dev.yml文件
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
在config.yml文件
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
在我parameters.yml文件
....
mailer_transport: gmail
mailer_host: 127.0.0.1
mailer_user: 'my_gamil_here'
mailer_password: 'my_password_here'
然后在我的骗局troller我有以下
public function indexAction(\Swift_Mailer $mailer)
{
$message = (new \Swift_Message('Hello Email'))
->setFrom('[email protected]')
->setTo('[email protected]')
->setBody(
$this->renderView(
// app/Resources/views/Emails/registration.html.twig
'Emails/registration.html.twig',
array('name' => 'James')
),
'text/html'
);
$mailer->send($message);
return new Response('Email sent');
}
}
有人能告诉我,我什么都错了。没有什么会被发送到电子邮件帐户。
这工作我的朋友。非常感谢你! – Kaley36