我无法使用symfony2发送电子邮件
应用/配置/ config.yml
swiftmailer:
transport: smtp
encryption: ssl
auth_mode: login
host: smtp.gmail.com
username: mymail@gmail.com
password: mypassword
SRC / GA / CmsBundle /资源/配置/ routing.yml中
emailing:
pattern: /emailing
defaults: { _controller: "GaCmsBundle:main:emailing" }
SRC / GA / CmsBundle /控制器/ mainController.php
public function emailingAction()
{
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('mymail@gmail.com')
->setTo('anothermail@yahoo.com')
->setBody('mahdi musawie');
$this->get('mailer')->send($message);
return new response("mahdi");
}
答案 0 :(得分:2)
尝试设置一个端口(这个是谷歌应用程序的465)或使用transport:gmail
这个适用于我:(我使用谷歌应用程序)
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: xxx@my-domain.com
mailer_password: xxx
mailer_port: 465