发送电子邮件时出现symfony2错误

发送电子邮件时出现symfony2错误,symfony,mailer,Symfony,Mailer,我正在用Symfony2开发一个应用程序 我有一个将在crontab中运行的命令 这是命令: <?php namespace project\projBundle\Service; use Doctrine\ORM\EntityManager; use Symfony\Component\Templating\EngineInterface; class Sender { protected $em; protected $templating; protected

我正在用Symfony2开发一个应用程序 我有一个将在crontab中运行的命令

这是命令:

<?php
namespace project\projBundle\Service;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Templating\EngineInterface;
class Sender {
    protected $em;
    protected $templating;
    protected $mailer;
    public function __construct($em, $templating,\Swift_Mailer $mailer) {
        $this->em = $em;
        $this->templating = $templating;
        $this->mailer = $mailer; }

    public function runSender() {
        $proj = $this->em->createQuery("query")->setMaxResults(20)->getResult();
        $message = \Swift_Message::newInstance()
            ->setSubject('Contact enquiry from symblog')
            ->setFrom('...@gmail.com')
            ->setTo('...@gmail.com')
            ->setBody($this->templating->render('projectprojBundle:Others:emailNew.html.twig', array('proj' => $proj)));

        $this->mailer->send($message); } }
在配置测试中:

swiftmailer:
disable_delivery: false
spool: { type: memory }
这是给我发电子邮件,但我收到两封电子邮件: 第一:

在第二个窗口中显示的是细枝代码,而不是渲染


我做错了什么?

您是否在config.yml中添加了以下内容:

swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%

我用它来固定树枝:

protected $twig;
    protected $mailer;
    public function __construct(\Twig_Environment $twig,\Swift_Mailer $mailer) {
        $this->twig = $twig;
        $this->mailer = $mailer;
    }

但现在的问题是,我仍然有html标记。

是的,它发送电子邮件,但我从邮件传递子系统和其他我想要但没有呈现的邮件接收电子邮件尝试使用$this->renderView()显示中的方法对于一个收件人,
gmail
之后的
.com
似乎丢失了。标记是否未被解释?尝试使用该函数。
swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
protected $twig;
    protected $mailer;
    public function __construct(\Twig_Environment $twig,\Swift_Mailer $mailer) {
        $this->twig = $twig;
        $this->mailer = $mailer;
    }