有没有一种方法可以取消或删除phpmailer中的msgHTML/view模板 [英] Is there a way to unset or delete msgHTML/view template in phpmailer

查看:174
本文介绍了有没有一种方法可以取消或删除phpmailer中的msgHTML/view模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有电子邮件回复形式的网站.单击时我需要发送2封电子邮件,并且正在使用苗条框架,msgHTML和twig.我按条件设置了树枝模板,以便在第一封电子邮件中显示该模板的一部分,而在另一封电子邮件中显示该模板的另一部分.不起作用,因为第一封电子邮件正文消息已添加到第二封电子邮件中.

I have a website with an email form response. I need to send 2 emails when clicked and is working with slim framework, msgHTML and twig. I set twig template by a condition to show one part of that template for the first email and other part for the another. Don't work because the first email body message was added to the second one.

因此,我创建了2个phpmailer实例来发送2个单独的树枝模板,但出现相同的错误,它在最后一封电子邮件正文消息中添加了2个模板.

So I created 2 instances of phpmailer to send 2 separate twig templates but the same error appears, it add the 2 templates in the last email body message.

是否可以取消设置msgHTML消息或视图?

Is there a way to unset the msgHTML message or the view?

$mailu = new PHPMailer; $maila = new PHPMailer;
$mailu->isHTML(true); $maila->isHTML(true);
$mailu->isSMTP(); $maila->isSMTP();
$mailu->Host = 'XXX'; $maila->Host = 'XXX';
$mailu->Port = 587; $maila->Port = 587;
$mailu->SMTPAuth = true; $maila->SMTPAuth = true;
$mailu->SMTPSecure = 'tls'; $maila->SMTPSecure = 'tls';
$mailu->Username = 'XXX; $maila->Username = 'XXX';
$mailu->Password = 'XXX'; $maila->Password = 'XXX';
$mailu->SMTPDebug = 0; $maila->SMTPDebug = 0;
$mailu->setLanguage('es'); $maila->setLanguage('es');
$mailu->CharSet="utf-8"; $maila->CharSet="utf-8";
$mailu->clearCustomHeaders(); $maila->clearCustomHeaders();
$mailu->Subject = $subject; $maila->Subject = $subject;

$marrayu = array('user'=>true, 'name'=>$name, 'email'=>$email, 'subject'=>$subject, 'message'=>$message, 'phone'=>$phone);
$mailu->msgHTML($this->view->render($response, 'templates/mailu.twig', array( "marray" => $marrayu )));
$mailu->setFrom($domainmail, 'NMV');
$mailu->addAddress($email, $name);
$mailu->addReplyTo($domainmail, 'NMV');
$mailu->send();

$marraya = array('user'=>false, 'name'=>$name, 'email'=>$email, 'subject'=>$subject, 'message'=>$message, 'phone'=>$phone);
$maila->msgHTML($this->view->render($response, 'templates/maila.twig', array( "marray" => $marraya )));
$maila->setFrom($email, $name);
$maila->addAddress($domainmail,'NMV');
$maila->send();

return $this->response->withStatus(200)->withHeader('Location',  $anchor);

有什么建议吗?

推荐答案

我在此帖子中找到了答案

I found the answer in this post Slim framework and email template rendering issue with PHPmailer

正如我所期望的,一切都很好,但是视图假定要加入渲染器,因此将其更改为fetch也是成功的窍门,因为我得到了HTTP/1.1 200 OK Content-Type:text/html;电子邮件顶部的charset = UTF-8标头.

As I expect, all was fine but the view was assuming the render to join, so change it to fetch made the trick also because I was getting the HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8 header in the top of the emails.

感谢您的帮助.

这篇关于有没有一种方法可以取消或删除phpmailer中的msgHTML/view模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆