通过电子邮件获取此响应“HTTP/1.0 200 OK缓存控制:无缓存内容类型:text/html; charset = UTF-8日期:2012年11月13日,星期二,格林尼治标准时间”。
这是我的代码:
public function sendEmail($subject, $template, $templateParams)
{
$userEmail = $this->session->get('email');
$name = $this->session->get('name');
$adminEmail = $this->container;
$templateParams['username'] = $name;
$message = \Swift_Message::newInstance()
->setSubject($subject)
->setFrom($adminEmail)
->setTo($userEmail)
->setBody($this->templating->render('SocialDonSocialBundle:Email:'.$template,$templateParams), 'text/html');
$this->mailer->send($message);
另请注意,此方法属于服务即“电子邮件”。我创建了一个服务“Email”,负责发送电子邮件。有人知道这可能是什么问题吗?
最佳答案
您需要使用renderView()而不是render(),因为render()始终显示 header 。
关于symfony - 使用symfony 2的快速邮件程序,收到了一封电子邮件,但在电子邮件中收到了不必要的回复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13357202/