我正在尝试用swiftMailer在Symfony 2.7.3中发送一封测试电子邮件,但是它不能工作。即使不是工作,我也看了很多帖子。这方面的常规配置通常是:
控制器:
$message = \Swift_Message::newInstance()
->setSubject('Mensaje de prueba')
->setFrom('prueba1@gmail.com')
->setTo('prueba2@gmail.com')
->setBody(
$this->renderView(
'GuiasDocentesAppBundle:FAQ:plantillaEmail.html.twig',
array('correoConsultante' => $correoConsultante)
),
'text/html'
)
;
$this->get('mailer')->send($message);
Parameters.yml:
{ parameters: {
database_host: 127.0.0.1,
database_port: null,
database_name: databasename,
database_user: databaseuser,
database_password: databasepassword,
mailer_transport: gmail,
mailer_host: smtp.gmail.com,
mailer_user: prueba1@gmail.com,
mailer_password: passwordforprueba1,
secret: *******************************,
database_driver: pdo_mysql,
database_path: null } }
config_dev.yml && config.yml:
swiftmailer:
transport: "%mailer_transport%"
encryption: ssl
auth_mode: login
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
实际上,我在开发环境中,但我认为这不是问题。如您所见,控制器和parameters.yml中的prueba1@gmail.com是相同的。正确的帐户(prueba1@gmail.com)已配置为在没有此link的外部应用程序工作,我希望有人能帮助我。谢谢
发布于 2016-05-19 20:08:00
在symfony 2.7中,我的一个应用程序也遇到了同样的问题
解决方案是假脱机电子邮件http://symfony.com/doc/2.7/cookbook/email/spool.html
并通过cron发送假脱机的电子邮件(解决方案很差劲-但对我来说很有效)
https://stackoverflow.com/questions/37299017
复制相似问题