使用symfony 2的swift mailer,收到了一封电子邮件,但收到了不必要的回复
通过电子邮件“HTTP/1.0 200 OK Cache Control:无缓存内容类型:text/html;charset=UTF-8日期:2012年11月13日星期二04:56:14 GMT”获取此响应 这是我的密码:使用symfony 2的swift mailer,收到了一封电子邮件,但收到了不必要的回复,symfony,twig,swiftmailer,Symfony,Twig,Swiftmailer,通过电子邮件“HTTP/1.0 200 OK Cache Control:无缓存内容类型:text/html;charset=UTF-8日期:2012年11月13日星期二04:56:14 GMT”获取此响应 这是我的密码: public function sendEmail($subject, $template, $templateParams) { $userEmail = $this->session->get('email'); $n
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);
还请注意,此方法属于一种服务,即“电子邮件”。我已经创建了一个服务“电子邮件”,负责发送电子邮件。有人知道可能是什么问题吗 您需要使用renderView()而不是render(),因为render()始终显示标题。在Symfony2的较新版本(如2.5版)中* 解决方案是使用renderResponse并对其执行getContent()操作: 或者使用与问题中相同的值:
$this->templating->renderResponse('SocialDonSocialBundle:Email:'.$template,$templateParams)->getContent();
我看不出你为什么会得到这些标题。你的模板是否做了一些奇怪的事情,比如输出头本身?我也知道了。你修好了吗?我也有同样的问题。谢谢你的回答
$this->templating->renderResponse('SocialDonSocialBundle:Email:'.$template,$templateParams)->getContent();